diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 16 |
1 files changed, 15 insertions, 1 deletions
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(()) } |