A quick HTTP fileserver
go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
614 B

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;
}