env-logger
All checks were successful
deploy / deploy (push) Successful in 4m33s

This commit is contained in:
2024-10-02 18:56:52 +03:00
parent bd3f3661c4
commit 1f35ef96d4
3 changed files with 104 additions and 1 deletions

View File

@@ -8,9 +8,12 @@ use actix_web::{middleware::Logger, web, App, HttpServer};
use app_state::AppState;
use handlers::{proxy_handler, upload_handler};
use tokio::task::spawn_blocking;
use std::env;
use env_logger;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::init();
let app_state = AppState::new().await;
let app_state_clone = app_state.clone();
@@ -24,6 +27,8 @@ async fn main() -> std::io::Result<()> {
});
});
let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string());
let addr = format!("0.0.0.0:{}", port);
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(app_state.clone()))
@@ -31,7 +36,7 @@ async fn main() -> std::io::Result<()> {
.route("/", web::post().to(upload_handler))
.route("/{path:.*}", web::get().to(proxy_handler))
})
.bind("127.0.0.1:8080")?
.bind(addr)?
.run()
.await
}