Include index.html in compile-time

This commit is contained in:
Ivan Bushchik 2023-06-18 10:59:51 +03:00
parent acdf0d39f2
commit df3e437b78
No known key found for this signature in database
GPG key ID: 9F6DDABE11A2674D

View file

@ -31,6 +31,8 @@ use rocket::response::content::RawHtml;
use std::fs::read_dir; use std::fs::read_dir;
use std::path::PathBuf; use std::path::PathBuf;
const INDEX: &'static str = include_str!("../index.html");
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]
struct Args { struct Args {
@ -57,10 +59,7 @@ struct StreamURL {
fn index() -> RawHtml<String> { fn index() -> RawHtml<String> {
let args = Args::parse(); let args = Args::parse();
let dir = read_dir(args.streams_dir).unwrap(); let dir = read_dir(args.streams_dir).unwrap();
let mut res = match smurf::io::read_file_to_str(&PathBuf::from("./index.html")) { let mut res = INDEX.to_string();
Some(s) => s,
None => String::new(),
};
let mut m3u8: Vec<StreamURL> = vec![]; let mut m3u8: Vec<StreamURL> = vec![];
for i in dir { for i in dir {
let path = i.unwrap().path(); let path = i.unwrap().path();