From 6640da7dce77f1b234b9ef618b4124ae4cb4fc58 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 19 May 2025 19:26:33 +0200 Subject: configurable port --- src/main.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 0441cc6..2ead48c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,6 +56,20 @@ async fn main() -> Result<()> { let mut state = State::default(); state.load_config().await?; state.load().await?; + + let bind_addr = state + .config + .get("bind_addr") + .and_then(Value::as_str) + .unwrap_or("127.0.0.1"); + let bind_port = state + .config + .get("bind_port") + .and_then(Value::as_u64) + .unwrap_or(44794) as u16; + + let listener = TcpListener::bind((bind_addr, bind_port)).await?; + let router = Router::new() .route("/", get(webui)) .route("/style.css", get(webui_style)) @@ -66,7 +80,7 @@ async fn main() -> Result<()> { .route("/api/complete.json", get(api_complete_json)) .route("/api/loading.json", get(api_loading_json)) .with_state(Arc::new(RwLock::new(state))); - let listener = TcpListener::bind("127.0.0.1:8080").await?; + axum::serve(listener, router).await?; Ok(()) } -- cgit v1.2.3-70-g09d2