From 5a45099e7b4b1b6fe03105f18a5216b115f74806 Mon Sep 17 00:00:00 2001 From: Franz Dietrich Date: Sun, 5 Feb 2023 11:53:26 +0100 Subject: [PATCH] get port from env --- .env | 2 +- terminwahl_back/src/main.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 9c8197b..4c7260c 100644 --- a/.env +++ b/.env @@ -2,5 +2,5 @@ DATABASE_URL="sqlite://terminwahl_back/db.sqlite" RUST_LOG="debug" SMTP_USER="SMTP_USERNAME" SMTP_PASSWORD="SMTP_PASSWORD" - +PORT="8087" PATH_TO_STATICS="terminwahl_front/dist/" diff --git a/terminwahl_back/src/main.rs b/terminwahl_back/src/main.rs index 5dc62c0..6cf6f93 100644 --- a/terminwahl_back/src/main.rs +++ b/terminwahl_back/src/main.rs @@ -25,6 +25,10 @@ async fn main() -> std::io::Result<()> { let smtp_user = env::var("SMTP_USER").expect("Failed to get smtp user"); let smtp_password = env::var("SMTP_PASSWORD").expect("Failed to get smtp password"); let wasm_statics = env::var("PATH_TO_STATICS").expect("Failed to get statics path"); + let port: u16 = env::var("PORT") + .expect("Failed to get port") + .parse() + .expect("Not a Portnumber"); let credentials = Credentials::new(smtp_user, smtp_password); let smtp_pool = SmtpTransport::relay("smtp.1und1.de") .expect("Failed to connect to smtp") @@ -88,7 +92,7 @@ async fn main() -> std::io::Result<()> { ) .service(Files::new("/", wasm_statics.clone()).index_file("index.html")) }) - .bind(("127.0.0.1", 8080))? + .bind(("127.0.0.1", port))? .workers(2) .run() .await