From df3e437b78181b5b3597bcdeaea7aa957b6045bc Mon Sep 17 00:00:00 2001 From: Ivan Bushchik Date: Sun, 18 Jun 2023 10:59:51 +0300 Subject: [PATCH] Include index.html in compile-time --- src/main.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index dd38de9..59cd07a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,8 @@ use rocket::response::content::RawHtml; use std::fs::read_dir; use std::path::PathBuf; +const INDEX: &'static str = include_str!("../index.html"); + #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { @@ -57,10 +59,7 @@ struct StreamURL { fn index() -> RawHtml { let args = Args::parse(); let dir = read_dir(args.streams_dir).unwrap(); - let mut res = match smurf::io::read_file_to_str(&PathBuf::from("./index.html")) { - Some(s) => s, - None => String::new(), - }; + let mut res = INDEX.to_string(); let mut m3u8: Vec = vec![]; for i in dir { let path = i.unwrap().path();