Skip to content

Commit

Permalink
Added cmd line parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
volker committed Feb 14, 2024
1 parent 596c8aa commit 6f710ad
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 52 deletions.
141 changes: 141 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ warp = "0.3"
warp-embed = "0.4"
rust-embed = "6"
log = "0.4"
env_logger = "0.10"
env_logger = "0.10"
structopt = "0.3.21"
26 changes: 23 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@ use warp::http::{StatusCode, Uri};
use rust_embed::RustEmbed;
use warp::reply::json;
use serde_json::json;
use std::net::IpAddr;
use structopt::StructOpt;

#[derive(RustEmbed)]
#[folder = "web/dist"]
struct Static;

#[derive(Debug, StructOpt)]
struct Opt {
#[structopt(long, default_value = "localhost")]
host: String,

#[structopt(long, default_value = "3030")]
port: u16,
}


#[tokio::main]
async fn main() {

Expand Down Expand Up @@ -62,8 +74,16 @@ async fn main() {
.allow_methods(vec!["GET", "POST"])
.allow_headers(vec!["Content-Type"]);

log::info!("Starting server on http://localhost:3030");

let opt = Opt::from_args();

log::info!("Starting server on http://{}:{}", opt.host, opt.port);
warp::serve(iptables.or(redirect).or(static_files).or(error).with(cors))
.run(([127, 0, 0, 1], 3030))
.run((opt.host.parse::<IpAddr>().unwrap(), opt.port))
.await;
}

}




48 changes: 0 additions & 48 deletions src/webserver_main.rs

This file was deleted.

0 comments on commit 6f710ad

Please sign in to comment.