quick rust website
This commit is contained in:
19
src/handlers.rs
Normal file
19
src/handlers.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use askama::Template;
|
||||
use axum::{
|
||||
http::StatusCode,
|
||||
response::{Html, IntoResponse},
|
||||
};
|
||||
|
||||
pub async fn render_homepage() -> impl IntoResponse {
|
||||
#[derive(Template)]
|
||||
#[template(path = "homepage.html")]
|
||||
struct HomePageTemplate<'a> {
|
||||
lang: &'a str,
|
||||
}
|
||||
|
||||
let tmpl = HomePageTemplate { lang: "en" };
|
||||
match tmpl.render() {
|
||||
Ok(html) => Html(html).into_response(),
|
||||
Err(_) => (StatusCode::INTERNAL_SERVER_ERROR, "Template render error").into_response(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user