From 69d6ea27423e1e24eed4ade064dfbb3b494cb888 Mon Sep 17 00:00:00 2001 From: Rusty Striker Date: Sun, 15 Jun 2025 18:36:19 +0300 Subject: [PATCH] read the file for every request to allow for faster web development --- src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index d5f3ed5..ef01f2d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ async fn main() { let game = open_tavern::GameServer::new(); tokio::spawn(game.server_loop(mrecv, bsend)); + println!("Server is running at http://localhost:3001"); axum::serve(listener, app) .await .expect("axum server crashed, yaaaaay (unless i crashed him that yay)"); @@ -167,26 +168,26 @@ async fn handle_socket( println!("Done with so-cat"); } -async fn root() -> axum::response::Html<&'static str> { - response::Html(include_str!("../assets/web/index.html")) +async fn root() -> axum::response::Html { + response::Html(std::fs::read_to_string("./assets/web/index.html").expect("Failed finding index.html")) } async fn socket() -> impl response::IntoResponse { ( [(axum::http::header::CONTENT_TYPE, "text/javascript")], - include_str!("../assets/web/tavern.js"), + std::fs::read_to_string("./assets/web/tavern.js").expect("Failed finding tavern.js"), ) } async fn app_js() -> impl response::IntoResponse { ( [(axum::http::header::CONTENT_TYPE, "text/javascript")], - include_str!("../assets/web/app.js"), + std::fs::read_to_string("./assets/web/app.js").expect("Failed finding app.js"), ) } async fn style() -> impl response::IntoResponse { ( [(axum::http::header::CONTENT_TYPE, "text/css")], - include_str!("../assets/web/style.css"), + std::fs::read_to_string("./assets/web/style.css").unwrap(), ) }