Web Design Update
This commit is contained in:
+11
@@ -76,6 +76,7 @@ async fn main() {
|
||||
|
||||
let app = Router::new()
|
||||
.route("/", get(list_files))
|
||||
.route("/image.png", get(serve_image))
|
||||
.route("/download/:file_id", get(download_file))
|
||||
.route("/health", get(health_check))
|
||||
.layer(middleware::from_fn_with_state(
|
||||
@@ -207,6 +208,16 @@ async fn health_check() -> impl IntoResponse {
|
||||
(StatusCode::OK, "OK")
|
||||
}
|
||||
|
||||
async fn serve_image() -> impl IntoResponse {
|
||||
match tokio::fs::read("templates/image.png").await {
|
||||
Ok(bytes) => (
|
||||
[(header::CONTENT_TYPE, "image/png")],
|
||||
bytes,
|
||||
).into_response(),
|
||||
Err(_) => StatusCode::NOT_FOUND.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
async fn list_files(State(state): State<AppState>) -> Html<String> {
|
||||
// Read template from file
|
||||
let template_path = "templates/index.html";
|
||||
|
||||
Reference in New Issue
Block a user