From 9d2f7536207f7fbac9cf78e8a13692ed941fa58a Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Tue, 5 Jul 2022 10:33:27 +0100 Subject: [PATCH] feat: Add env var to change port --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index d3dbb90..bd7783b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,11 @@ async fn main() -> Result<()> { let app = routes::router() .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()) .await?;