1
0

Fix bind address of server

This commit is contained in:
2024-02-03 02:48:03 +00:00
parent 54c0b7747a
commit 24f591fe90

View File

@@ -3,8 +3,6 @@ use tera::Tera;
use crate::{handlers, templates, Args};
const ADDRESS: &str = "127.0.0.1";
pub async fn run(args: &Args) -> Result<(), ServerError> {
std::fs::create_dir_all(&args.schem_dir_path)?;
@@ -12,6 +10,8 @@ pub async fn run(args: &Args) -> Result<(), ServerError> {
let mut tera = Tera::default();
tera.add_raw_template("index.html", templates::INDEX_HTML)?;
println!("server running and listening on {}:{}", args.address, args.port);
HttpServer::new(move || {
App::new()
.app_data(Data::new(cloned_args.clone()))
@@ -22,7 +22,7 @@ pub async fn run(args: &Args) -> Result<(), ServerError> {
.route("/download/{filename:.*}", web::get().to(handlers::download))
.route("/upload", web::post().to(handlers::upload))
})
.bind((ADDRESS, args.port))?
.bind((args.address.clone(), args.port))?
.run()
.await?;