Merge pull request #2 from calcu1on/issue-1

Switch to json 404.
This commit is contained in:
calcu1on 2024-12-22 20:35:22 -05:00 committed by GitHub
commit 411efe5276
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 11 deletions

View File

@ -1,9 +0,0 @@
<!Doctype html>
<html>
<head>
<title>Page Not Found | Hermes</title>
</head>
<body>
<p>The requested page could not be found.</p>
</body>
</html>

3
public/404.json Normal file
View File

@ -0,0 +1,3 @@
{
"detail": "Route not found, or request malformed...thats all im saying."
}

View File

@ -12,7 +12,12 @@ struct IncomingRequest {
// Listen on port and return response. // Listen on port and return response.
fn main() { 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() { for stream in listener.incoming() {
let stream = stream.unwrap(); let stream = stream.unwrap();
@ -70,7 +75,7 @@ fn get_api_key(headers: Vec<String>) -> String {
// Return a 404. // Return a 404.
fn return_404() -> String { fn return_404() -> String {
let status_line = "HTTP/1.1 404 Not Found"; 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 length = contents.len();
let response = let response =