This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user