split index.html to multiple files

This commit is contained in:
Rusty Striker 2024-10-18 16:07:10 +03:00
parent a6bfd86c24
commit af11db6f55
Signed by: RustyStriker
GPG key ID: 87E4D691632DFF15
5 changed files with 356 additions and 347 deletions

View file

@ -12,7 +12,9 @@ async fn main() {
let bsend2 = bsend.clone();
let app = Router::new()
.route("/", routing::get(root))
.route("/socket.js", routing::get(socket))
.route("/tavern.js", routing::get(socket))
.route("/app.js", routing::get(app_js))
.route("/style.css", routing::get(style))
.route("/ws", routing::get(move |w| ws_handler(w, msend, bsend2.clone().subscribe())));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3001").await.unwrap();
@ -135,7 +137,14 @@ async fn root() -> axum::response::Html<&'static str> {
response::Html(include_str!("../assets/web/index.html"))
}
async fn socket() -> &'static str {
include_str!("../assets/web/socket.js")
async fn socket() -> impl response::IntoResponse {
([(axum::http::header::CONTENT_TYPE, "text/javascript")], include_str!("../assets/web/tavern.js"))
}
async fn app_js() -> impl response::IntoResponse {
([(axum::http::header::CONTENT_TYPE, "text/javascript")], include_str!("../assets/web/app.js"))
}
async fn style() -> impl response::IntoResponse {
([(axum::http::header::CONTENT_TYPE, "text/css")], include_str!("../assets/web/style.css"))
}