Implemented user specifieable host and port

This commit is contained in:
Gvidas Juknevičius 2024-03-23 22:29:28 +02:00
parent 46e3eea247
commit bd7dce7981
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
2 changed files with 8 additions and 4 deletions

View File

@ -10,7 +10,7 @@ async fn main() -> std::io::Result<()> {
logger::init_logger(&cli);
if let Err(e) = public::start_actix().await {
if let Err(e) = public::start_actix(&cli).await {
log::error!("Actix had an error: {e}");
}
Ok(())

View File

@ -4,14 +4,18 @@ mod templates;
use actix_web::{web, App, HttpServer};
pub(crate) async fn start_actix() -> anyhow::Result<()> {
log::info!("Serving an http server at http://0.0.0.0:8080");
use crate::cli::CliArgs;
pub(crate) async fn start_actix(cli: &CliArgs) -> anyhow::Result<()> {
let bindip = format!("{}:{}", cli.host, cli.port);
log::info!("Serving an http server at http://{bindip}");
HttpServer::new(|| {
App::new()
.route("/", web::get().to(routes::index))
})
.bind("0.0.0.0:8080")?
.bind(bindip)?
.run()
.await?;