aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/args.rs1
-rw-r--r--src/main.rs11
2 files changed, 12 insertions, 0 deletions
diff --git a/src/args.rs b/src/args.rs
index b4b50e2..6a3a4a5 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -166,6 +166,7 @@ pub fn parse_args() -> crate::MiniserveConfig {
no_symlinks: args.no_symlinks,
random_route,
default_color_scheme,
+ default_index: args.default_index,
overwrite_files: args.overwrite_files,
file_upload: args.file_upload,
}
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(