forked from spacebar/spfn-website
Add Backend
This commit is contained in:
parent
dc101e28f8
commit
05beab587b
31 changed files with 59 additions and 6 deletions
25
src/main.rs
Normal file
25
src/main.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
use std::env;
|
||||
use axum::Router;
|
||||
use tower_http::services::ServeDir;
|
||||
use dotenvy::dotenv;
|
||||
|
||||
#[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()
|
||||
.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();
|
||||
}
|
||||
Loading…
Reference in a new issue