From 484d62913300d6f3ce73522affc91ff6384d11d9 Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Fri, 21 Feb 2025 17:33:00 +0100 Subject: Compile Elm to js instead of html --- Makefile | 2 +- front/.gitignore | 1 + front/src/Main.elm | 2 +- src/bin/web.rs | 24 +++++++++++++++++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1c39913..ad7cba4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ build: - cd front && elm make src/Main.elm + cd front && elm make src/Main.elm --output main.js cargo build -r serve: build diff --git a/front/.gitignore b/front/.gitignore index e453cba..9e98d05 100644 --- a/front/.gitignore +++ b/front/.gitignore @@ -1,2 +1,3 @@ elm-stuff index.html +main.js diff --git a/front/src/Main.elm b/front/src/Main.elm index 9139158..7f6522b 100644 --- a/front/src/Main.elm +++ b/front/src/Main.elm @@ -1,4 +1,4 @@ -module Main exposing (..) +module Main exposing (main) import Round import Browser diff --git a/src/bin/web.rs b/src/bin/web.rs index 86effcf..4b63572 100644 --- a/src/bin/web.rs +++ b/src/bin/web.rs @@ -10,7 +10,28 @@ use axum::{ }; async fn root_get() -> Html { - Html(fs::read_to_string("front/index.html").unwrap()) + let head = " + + + Hiccup + + + "; + let body = " + +
+ + + "; + Html(format!("{head}{body}")) +} + +async fn main_get() -> Html { + Html(fs::read_to_string("front/main.js").unwrap()) } #[derive(Deserialize)] @@ -32,6 +53,7 @@ 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("/api/simulate", get(api_simulate_get)); // run our app with hyper, listening globally on port 3000 -- cgit v1.2.3