quickserv/src/main.rs

27 lines
614 B
Rust
Raw Normal View History

2020-05-28 18:47:28 +00:00
use std::path::PathBuf;
use structopt::StructOpt;
/// A basic example
#[derive(StructOpt, Debug)]
#[structopt(name = "quickserv")]
struct Opt {
// The HTTP port to listen on
#[structopt(short, long, env="PORT", default_value="9001")]
port: u16,
// The path to serve
#[structopt(short, long, env="DIR", default_value=".")]
dir: PathBuf,
}
#[tokio::main]
async fn main() {
env_logger::init();
let opt = Opt::from_args();
log::info!("serving {:?} on port {}", opt.dir, opt.port);
warp::serve(warp::fs::dir(opt.dir))
.run(([0, 0, 0, 0], opt.port))
.await;
}