From eacb0f2e62b3a713083be9cc15b8af41fac2d6af Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Mon, 4 Dec 2023 08:06:31 -0600 Subject: Add static assets in a single binary --- bin/main.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/main.ml b/bin/main.ml index 49469a3..45bd973 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -67,6 +67,11 @@ let actor_allowlist = "https://graphics.social/users/theohonohan"; ] +let loader _root path _request = + match Assets.read path with + | None -> Dream.empty `Not_Found + | Some asset -> Dream.respond asset + let () = let port = Sys.getenv_opt "PORT" |> Option.map int_of_string @@ -84,7 +89,7 @@ let () = Dream.run ~port ~interface @@ Dream.logger @@ Dream.router [ - Dream.get "/static/**" (Dream.static "./assets"); + Dream.get "/static/**" (Dream.static ~loader ""); Dream.get "/feed.xml" (fun _ -> let posts = Post.get_all () in let maybe_latest_post = Post.latest_post () in -- cgit v1.2.3