spfn-website/src/main.rs

28 lines
649 B
Rust

use std::env;
use axum::Router;
use tower_http::services::ServeDir;
use dotenvy::dotenv;
mod api;
#[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()
.nest("/api", api::router())
.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();
}