diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index dc98df0..46c38d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ use simplelog::{Config, LevelFilter, TermLogger, TerminalMode}; use std::io::{self, Write}; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::thread; +use std::path::PathBuf; use std::time::Duration; use yansi::{Color, Paint}; @@ -52,6 +53,9 @@ pub struct MiniserveConfig { /// Default color scheme pub default_color_scheme: themes::ColorScheme, + /// Serve index.* files by default + pub default_index: bool, + /// Enable file upload pub file_upload: bool, @@ -234,6 +238,13 @@ fn configure_app(app: App<MiniserveConfig>) -> App<MiniserveConfig> { }; if path.is_file() { None + } else if app.state().default_index == true { + let mut index_path = PathBuf::from(path); + index_path.push("index.html"); + Some( + fs::StaticFiles::new(index_path) + .expect("Failed to setup static file handler") + ) } else { let u_r = upload_route.clone(); Some( |