|
|
@ -8,9 +8,8 @@ use crate::post::{Post, Thread};
|
|
|
|
|
|
|
|
|
|
|
|
use std::io;
|
|
|
|
use std::io;
|
|
|
|
use std::io::{BufRead, BufReader, Read, Write};
|
|
|
|
use std::io::{BufRead, BufReader, Read, Write};
|
|
|
|
use std::net::{SocketAddr, TcpListener, TcpStream};
|
|
|
|
use std::net::{TcpListener, TcpStream};
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::str;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use bincode::{deserialize, serialize};
|
|
|
|
use bincode::{deserialize, serialize};
|
|
|
|
use errors::DatabaseError;
|
|
|
|
use errors::DatabaseError;
|
|
|
@ -37,6 +36,9 @@ struct Opt {
|
|
|
|
|
|
|
|
|
|
|
|
#[structopt(short, long, default_value = "data")]
|
|
|
|
#[structopt(short, long, default_value = "data")]
|
|
|
|
database: PathBuf,
|
|
|
|
database: PathBuf,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[structopt(short, long, default_value = "999999999")]
|
|
|
|
|
|
|
|
max_id: u32,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// get command line arguments and make them static
|
|
|
|
// get command line arguments and make them static
|
|
|
@ -215,15 +217,23 @@ fn get(path: &str) -> Result<Response, HandlingError> {
|
|
|
|
.fold(String::from(""), |a, b| format!("{a}\n{b}"));
|
|
|
|
.fold(String::from(""), |a, b| format!("{a}\n{b}"));
|
|
|
|
let c = content("index", &ops);
|
|
|
|
let c = content("index", &ops);
|
|
|
|
|
|
|
|
|
|
|
|
Ok(Response::new(Status::Ok, vec![], c.into()))
|
|
|
|
Ok(Response::new(
|
|
|
|
|
|
|
|
Status::Ok,
|
|
|
|
|
|
|
|
vec![("content-type", "text/html; charset=utf-8")],
|
|
|
|
|
|
|
|
c.into(),
|
|
|
|
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO favicon.ico
|
|
|
|
// TODO favicon.ico
|
|
|
|
"/css" => Ok(Response::new(
|
|
|
|
"/css" => Ok(Response::new(
|
|
|
|
Status::Ok,
|
|
|
|
Status::Ok,
|
|
|
|
vec![],
|
|
|
|
vec![("content-type", "text/css; charset=utf-8")],
|
|
|
|
String::from(STYLE).into(),
|
|
|
|
String::from(STYLE).into(),
|
|
|
|
)),
|
|
|
|
)),
|
|
|
|
"/faq" => Ok(Response::new(Status::Ok, vec![], String::from(FAQ).into())),
|
|
|
|
"/faq" => Ok(Response::new(
|
|
|
|
|
|
|
|
Status::Ok,
|
|
|
|
|
|
|
|
vec![("content-type", "text/html; charset=utf-8")],
|
|
|
|
|
|
|
|
String::from(FAQ).into(),
|
|
|
|
|
|
|
|
)),
|
|
|
|
"/favicon.ico" => Ok(Response::new(
|
|
|
|
"/favicon.ico" => Ok(Response::new(
|
|
|
|
Status::Ok,
|
|
|
|
Status::Ok,
|
|
|
|
vec![("content-type", "image/x-icon")],
|
|
|
|
vec![("content-type", "image/x-icon")],
|
|
|
@ -250,7 +260,11 @@ fn get(path: &str) -> Result<Response, HandlingError> {
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
.fold(String::from(""), |a, b| format!("{a}\n{b}"));
|
|
|
|
.fold(String::from(""), |a, b| format!("{a}\n{b}"));
|
|
|
|
let c = content(&id.to_string(), &c);
|
|
|
|
let c = content(&id.to_string(), &c);
|
|
|
|
Ok(Response::new(Status::Ok, vec![], c.into()))
|
|
|
|
Ok(Response::new(
|
|
|
|
|
|
|
|
Status::Ok,
|
|
|
|
|
|
|
|
vec![("content-type", "text/html; charset=utf-8")],
|
|
|
|
|
|
|
|
c.into(),
|
|
|
|
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|