init
This commit is contained in:
26
src/main.rs
Normal file
26
src/main.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
mod server;
|
||||
mod router;
|
||||
mod response;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use logger_rust::*;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
let port: u16 = args.get(1)
|
||||
.and_then(|p| p.parse().ok())
|
||||
.unwrap_or(8080);
|
||||
|
||||
let root = Arc::new(
|
||||
PathBuf::from(args.get(2).map(|s| s.as_str()).unwrap_or("."))
|
||||
);
|
||||
|
||||
if !root.exists() || !root.is_dir() {
|
||||
log_error!("Root {} isnt a valid directory", root.display());
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
server::run(root, port);
|
||||
}
|
||||
Reference in New Issue
Block a user