aboutsummaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorGuillermo Ramos2025-03-15 13:16:34 +0100
committerGuillermo Ramos2025-03-15 13:31:33 +0100
commit8dff02998db9eac1efacf555ccbdec198d7fe213 (patch)
tree64900ce5d82519ce54e87d18cbfa4f509be32c38 /src/bin
parent5feb5cf771d473ff9f55be40169ca5db2bafd268 (diff)
downloadhiccup-8dff02998db9eac1efacf555ccbdec198d7fe213.tar.gz
Self hosted TailwindCSS
Diffstat (limited to 'src/bin')
-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