From ff2c84fb33a79863f0c783d30e1322481328f997 Mon Sep 17 00:00:00 2001 From: Florian Briand Date: Wed, 24 Jul 2024 20:36:16 +0200 Subject: [PATCH] fix: base assets path on the manifest dir when running the webserver manually --- crates/clego/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/clego/src/main.rs b/crates/clego/src/main.rs index bfbfd83..00b4fdf 100644 --- a/crates/clego/src/main.rs +++ b/crates/clego/src/main.rs @@ -1,9 +1,12 @@ use ::clego::get_router; use std::path::Path; +use std::env; #[tokio::main] async fn main() { - let router = get_router(Path::new("/assets")); + let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let assets_path = Path::new(&manifest_dir).join("assets"); + let router = get_router(assets_path.as_path()); // TODO: select port based on available port (or ask in CLI) let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();