fix: base assets path on the manifest dir when running the webserver manually

This commit is contained in:
Florian Briand 2024-07-24 20:36:16 +02:00
parent b807e78ac3
commit ff2c84fb33
Signed by: florian_briand
GPG Key ID: CC981B9E6B98E70B

View File

@ -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();