spfn-website/src/main.rs

28 lines
649 B
Rust
Raw Permalink Normal View History

2026-06-23 17:17:57 +01:00
use std::env;
use axum::Router;
use tower_http::services::ServeDir;
use dotenvy::dotenv;
2026-06-23 19:36:04 +01:00
mod api;
2026-06-23 17:17:57 +01:00
#[tokio::main]
async fn main() {
dotenv().ok();
let host = env::var("APP_HOST").unwrap_or("0.0.0.0".into());
let port = env::var("APP_PORT").unwrap_or("80".into());
let app = Router::new()
2026-06-23 19:36:04 +01:00
.nest("/api", api::router())
2026-06-23 17:17:57 +01:00
.fallback_service(ServeDir::new("static"));
let listener = tokio::net::TcpListener::bind(format!("{}:{}", host, port))
.await
.unwrap();
println!("Website Hosting with Host {} and Port {}", host, port);
axum::serve(listener, app)
.await
.unwrap();
}