feat(frontend): add 404 page
This commit is contained in:
parent
44d87a8ffb
commit
932dd9264b
@ -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
11
templates/404.html
Normal 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 %}
|
Loading…
Reference in New Issue
Block a user