small fix
This commit is contained in:
@@ -3,4 +3,4 @@
|
|||||||
"/results": "static/html/results.html",
|
"/results": "static/html/results.html",
|
||||||
"/archives": "static/html/archives.html",
|
"/archives": "static/html/archives.html",
|
||||||
"/favicon.ico": "static/img/favicon.ico"
|
"/favicon.ico": "static/img/favicon.ico"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"database_url": "sqlite:vote.db",
|
"database_url": "sqlite:vote.db",
|
||||||
"bind_address": "127.0.0.1:8000"
|
"bind_address": "127.0.0.1:8080"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,12 +179,12 @@ async fn get_votes(req: &Request<Incoming>, db: Arc<Mutex<SqlitePool>>) -> Vec<V
|
|||||||
async fn post(req: Request<Incoming>, db: Arc<Mutex<SqlitePool>>) -> Result<Response<Full<Bytes>>, Error> {
|
async fn post(req: Request<Incoming>, db: Arc<Mutex<SqlitePool>>) -> Result<Response<Full<Bytes>>, Error> {
|
||||||
let path = req.uri().path();
|
let path = req.uri().path();
|
||||||
if path != "/post" {
|
if path != "/post" {
|
||||||
return Ok(Response::builder().status(StatusCode::BAD_REQUEST).body(Full::new(Bytes::from("Bad Request"))).unwrap());
|
return Ok(Response::builder().status(StatusCode::BAD_REQUEST).body(Full::new(Bytes::from("Bad Request (Bad Route)"))).unwrap());
|
||||||
}
|
}
|
||||||
let body = req.into_body().collect().await?;
|
let body = req.into_body().collect().await?;
|
||||||
let data: Result<Vote, serde_json::Error> = from_reader(body.aggregate().reader());
|
let data: Result<Vote, serde_json::Error> = from_reader(body.aggregate().reader());
|
||||||
if data.is_err() {
|
if data.is_err() {
|
||||||
return Ok(Response::builder().status(StatusCode::BAD_REQUEST).body(Full::new(Bytes::from("Bad Request"))).unwrap());
|
return Ok(Response::builder().status(StatusCode::BAD_REQUEST).body(Full::new(Bytes::from("Bad Request (Bad Data)"))).unwrap());
|
||||||
}
|
}
|
||||||
let vote = data.unwrap();
|
let vote = data.unwrap();
|
||||||
let timestamp: DateTime<Utc> = DateTime::from(SystemTime::now());
|
let timestamp: DateTime<Utc> = DateTime::from(SystemTime::now());
|
||||||
@@ -233,7 +233,7 @@ async fn main() {
|
|||||||
let daemonize = Daemonize::new()
|
let daemonize = Daemonize::new()
|
||||||
.pid_file("/var/vote/server.pid")
|
.pid_file("/var/vote/server.pid")
|
||||||
.chown_pid_file(true)
|
.chown_pid_file(true)
|
||||||
.working_directory(current_directory.to_str().unwrap())
|
.working_directory(current_directory)
|
||||||
.stdout(stdout)
|
.stdout(stdout)
|
||||||
.stderr(stderr);
|
.stderr(stderr);
|
||||||
match daemonize.start() {
|
match daemonize.start() {
|
||||||
|
|||||||
Reference in New Issue
Block a user