aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/web.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/bin/web.rs b/src/bin/web.rs
index eba283c..0384d7f 100644
--- a/src/bin/web.rs
+++ b/src/bin/web.rs
@@ -3,7 +3,8 @@ use serde::Deserialize;
use std::fs;
use axum::{
- response::{Html, Json},
+ http::header::CONTENT_TYPE,
+ response::{Html, Json, IntoResponse},
routing::{get, post},
Router,
};
@@ -13,7 +14,7 @@ async fn root_get() -> Html<String> {
<head>
<meta charset=\"UTF-8\">
<title>Hiccup</title>
- <script src=\"https://unpkg.com/@tailwindcss/browser@4\"></script>
+ <link href=\"/main.css\" rel=\"stylesheet\">
<script src=\"/main.js\"></script>
</head>
";
@@ -30,8 +31,12 @@ async fn root_get() -> Html<String> {
Html(format!("<!DOCTYPE html>{head}{body}"))
}
-async fn main_get() -> Html<String> {
- Html(fs::read_to_string("front/main.js").unwrap())
+async fn main_js_get() -> impl IntoResponse {
+ ([(CONTENT_TYPE, "text/javascript")], fs::read_to_string("front/main.js").unwrap())
+}
+
+async fn main_css_get() -> impl IntoResponse {
+ ([(CONTENT_TYPE, "text/css")], fs::read_to_string("front/main.css").unwrap())
}
#[derive(Deserialize)]
@@ -55,7 +60,8 @@ async fn main() {
// build our application with a single route
let app = Router::new()
.route("/", get(root_get))
- .route("/main.js", get(main_get))
+ .route("/main.js", get(main_js_get))
+ .route("/main.css", get(main_css_get))
.route("/api/simulate", post(api_simulate_post));
// run our app with hyper, listening globally on port 3000