Handle index.htm as well

This commit is contained in:
blank X 2021-05-11 21:11:31 +07:00
parent 3d1624532a
commit ef9b08fd89
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 4 additions and 2 deletions

View File

@ -37,7 +37,8 @@ async fn async_main(port: u16) {
let root_handler = warp::path::end().map(|| warp::reply::html(
format!("<html><head><title>ImgurX v{0}</title><style>body {{ background-color: black; color: black; text-align: center; }}\ndiv {{ border: 1px solid #008; background: #eef; padding: 0.5em 1em 0.5em 1em; }}</style></head><body><div><b><a href=\"https://gitlab.com/blankX/imgurx\" style=\"text-decoration: none;\">ImgurX v{0}</a></b><br>An alternative JS-less Imgur frontend</div></body></html>", env!("CARGO_PKG_VERSION"))
));
let index_handler = warp::path("index.html").and(root_handler);
let index_html_handler = warp::path("index.html").and(root_handler);
let index_htm_handler = warp::path("index.htm").and(root_handler);
let not_found_handler = warp::any().map(|| warp::reply::with_status(
warp::reply::html("<html><head><title>404: Not Found</title><style>body { background-color: black; color: white; text-align: center; }\ndiv { border: 1px solid #fcc; background: #fee; padding: 0.5em 1em 0.5em 1em; color: black; }</style></head><body><div><b>404: Not Found</b></div></body></html>"),
404.try_into().unwrap(),
@ -45,7 +46,8 @@ async fn async_main(port: u16) {
let routes = warp::filters::method::get().and(
album_path
.or(gallery_path)
.or(index_handler)
.or(index_html_handler)
.or(index_htm_handler)
.or(media_path)
.or(root_handler)
.or(not_found_handler),