read the file for every request to allow for faster web development
This commit is contained in:
parent
bdb0436c9f
commit
69d6ea2742
1 changed files with 6 additions and 5 deletions
11
src/main.rs
11
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<String> {
|
||||
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(),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue