blob: edf8be17f0ebf06f6b61c7aa21a597dabe218a26 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
use anyhow::Result;
use log::{debug, error};
use std::env;
use std::io::prelude::*;
mod config;
mod templates;
fn main() {
if let Err(e) = || -> Result<()> {
env_logger::Builder::from_env(config::LOGLEVEL).init();
let config = config::init()?;
let reg = templates::init();
let vars = env::vars();
let mut input = String::new();
std::io::stdin().read_to_string(&mut input).unwrap();
debug!("Final starting input: {input}");
debug!("Final starting config: {:?}", config);
if (env::var("PATH_INFO")? == "/status") {
status();
} else {
println!("content-type: text/html\n");
println!("{}", reg.render("index", &String::new())?);
}
Ok(())
}() {
error!("{:#}", e);
println!("content-type: text/plain\n\n500");
}
}
fn status() {
let vars = env::vars();
let mut input = String::new();
// begin writing
println!("Content-Type: text/html\n\n<html><body><ul>");
for each in vars {
println!("<li>{:?}</li>", &each);
}
println!("{:?}", &input);
}
|