batflip/src/router.rs

25 lines
700 B
Rust
Raw Normal View History

2025-04-11 16:39:17 -04:00
use std::fs;
pub fn get_route_data(route: &str) -> String {
match route {
2025-04-11 16:39:17 -04:00
"/" => {
return fs::read_to_string("./public/index.html").unwrap();
2025-04-11 16:39:17 -04:00
},
"/about" => {
return fs::read_to_string("./public/pages/about.html").unwrap();
2025-04-11 16:39:17 -04:00
}
_ if route.contains("assets") => {
let mut public_route: String = "./public".to_string();
public_route.push_str(&route);
return fs::read_to_string(&public_route).unwrap()
},
2025-04-11 16:39:17 -04:00
&_ => {
return fs::read_to_string("./public/404.html").unwrap();
}
}
}
// pub fn path_exists(path: &str) -> bool {
// fs::metadata(path).is_ok()
// }