disable browser/ui serving if folder not found
parent
6bc4e7ffce
commit
636da63c76
14
src/main.rs
14
src/main.rs
|
@ -104,7 +104,11 @@ fn main() -> Result<()> {
|
|||
};
|
||||
|
||||
// Start HTTP server
|
||||
let ui_enabled = !matches.is_present("NO_UI");
|
||||
let ui_path = env::current_exe().unwrap().parent().unwrap().join("webui");
|
||||
if !ui_path.exists() {
|
||||
warn!("No Web UI directory present ({:?}), disabling...", ui_path);
|
||||
}
|
||||
let ui_enabled = ui_path.exists() && !matches.is_present("NO_UI");
|
||||
HttpServer::new(move || {
|
||||
let app = App::new()
|
||||
.data(state.clone())
|
||||
|
@ -122,13 +126,7 @@ fn main() -> Result<()> {
|
|||
.service(routes::get_info);
|
||||
|
||||
if ui_enabled {
|
||||
app.service(
|
||||
actix_files::Files::new(
|
||||
"/",
|
||||
env::current_exe().unwrap().parent().unwrap().join("webui"),
|
||||
)
|
||||
.index_file("index.html"),
|
||||
)
|
||||
app.service(actix_files::Files::new("/", &ui_path).index_file("index.html"))
|
||||
} else {
|
||||
app
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue