use askama::Template; use axum::response::{IntoResponse, Html}; use axum::body::{Full, Bytes}; use axum::http::{Response, StatusCode}; use std::convert::Infallible; pub struct HtmlTemplate(pub T); impl IntoResponse for HtmlTemplate where T: Template, { type Body = Full; type BodyError = Infallible; fn into_response(self) -> Response { match self.0.render() { Ok(html) => Html(html).into_response(), Err(_) => (StatusCode::INTERNAL_SERVER_ERROR, "").into_response() } } } #[derive(Template)] #[template(path = "dir.html")] pub struct DirTemplate { pub entries: Vec, pub prefix: String, pub suffix: String, }