2025-04-11 16:39:17 -04:00
|
|
|
use std::fs;
|
2025-01-05 11:26:21 -05:00
|
|
|
|
|
|
|
|
pub fn get_route_data(route: &str) -> String {
|
|
|
|
|
match route {
|
2025-04-11 16:39:17 -04:00
|
|
|
"/" => {
|
2025-04-20 23:43:18 -04:00
|
|
|
return fs::read_to_string("./public/index.html").unwrap();
|
2025-04-11 16:39:17 -04:00
|
|
|
},
|
|
|
|
|
"/about" => {
|
2025-04-20 23:43:18 -04:00
|
|
|
return fs::read_to_string("./public/pages/about.html").unwrap();
|
2025-04-11 16:39:17 -04:00
|
|
|
}
|
2025-04-20 23:43:18 -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
|
|
|
&_ => {
|
2025-04-20 23:43:18 -04:00
|
|
|
return fs::read_to_string("./public/404.html").unwrap();
|
2025-01-05 11:26:21 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-20 23:43:18 -04:00
|
|
|
// pub fn path_exists(path: &str) -> bool {
|
|
|
|
|
// fs::metadata(path).is_ok()
|
|
|
|
|
// }
|