feat(frontend): add 404 page

This commit is contained in:
Mariano Riefolo 2024-09-15 14:09:31 +02:00
parent 44d87a8ffb
commit 932dd9264b
2 changed files with 22 additions and 0 deletions

View File

@ -10,6 +10,7 @@ pub fn get_routes() -> axum::Router {
axum::Router::new()
.route("/", get(index))
.nest_service("/static", ServeDir::new("static"))
.fallback(not_found)
}
#[derive(Template)]
@ -21,3 +22,13 @@ async fn index() -> impl IntoResponse {
let html = template.render().unwrap();
(StatusCode::OK, Html(html).into_response())
}
#[derive(Template)]
#[template(path = "404.html")]
struct NotFoundTemplate {}
async fn not_found() -> impl IntoResponse {
let template = NotFoundTemplate {};
let html = template.render().unwrap();
(StatusCode::NOT_FOUND, Html(html).into_response())
}

11
templates/404.html Normal file
View File

@ -0,0 +1,11 @@
{% extends "base.html" %} {% block title %}Pagina non trovata{% endblock %} {%
block head %}
<style>
main {
text-align: center;
}
</style>
{% endblock %} {% block content %}
<h1>404 Pagina non trovata</h1>
<p>La pagina che stai cercando non esiste.</p>
{% endblock %}