feat: Add env var to change port

This commit is contained in:
Ashhhleyyy 2022-07-05 10:33:27 +01:00
parent 94b32f9a1f
commit 9d2f753620
Signed by: ash
GPG key ID: 83B789081A0878FB

View file

@ -30,7 +30,11 @@ async fn main() -> Result<()> {
let app = routes::router() let app = routes::router()
.layer(Extension(AuthToken(upload_token))); .layer(Extension(AuthToken(upload_token)));
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap()) let port: u16 = std::env::var("PORT")
.map(|s| s.parse().unwrap())
.unwrap_or(3000);
axum::Server::bind(&format!("0.0.0.0:{port}").parse().unwrap())
.serve(app.into_make_service()) .serve(app.into_make_service())
.await?; .await?;