From 7c58f9db5175e247b4335a98737e2ea904e52cf3 Mon Sep 17 00:00:00 2001 From: calcu1on Date: Sun, 22 Dec 2024 20:37:04 -0500 Subject: [PATCH] Switch to json 404. --- public/404.html | 9 --------- public/404.json | 3 +++ src/main.rs | 9 +++++++-- 3 files changed, 10 insertions(+), 11 deletions(-) delete mode 100644 public/404.html create mode 100644 public/404.json diff --git a/public/404.html b/public/404.html deleted file mode 100644 index 22dfb0b..0000000 --- a/public/404.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Page Not Found | Hermes - - -

The requested page could not be found.

- - diff --git a/public/404.json b/public/404.json new file mode 100644 index 0000000..34a517a --- /dev/null +++ b/public/404.json @@ -0,0 +1,3 @@ +{ + "detail": "Route not found, or request malformed...thats all im saying." +} diff --git a/src/main.rs b/src/main.rs index 47eac09..b642551 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,12 @@ struct IncomingRequest { // Listen on port and return response. fn main() { - let listener = TcpListener::bind("164.92.85.112:7878").unwrap(); + let run_local = false; + let mut listener = TcpListener::bind("127.0.0.1:6942").unwrap(); + + if !run_local { + listener = TcpListener::bind("164.92.85.112:7878").unwrap(); + } for stream in listener.incoming() { let stream = stream.unwrap(); @@ -70,7 +75,7 @@ fn get_api_key(headers: Vec) -> String { // Return a 404. fn return_404() -> String { let status_line = "HTTP/1.1 404 Not Found"; - let contents = fs::read_to_string("./public/404.html").unwrap(); + let contents = fs::read_to_string("./public/404.json").unwrap(); let length = contents.len(); let response =