404: add page

This commit is contained in:
Agahnim 2026-03-19 18:10:05 +01:00
parent b7b866834b
commit db3c7657a3
Signed by: Agahnim
SSH key fingerprint: SHA256:Zj65PJnE0dRYye8Ltk/qDglynyXUxJngQ9qqx/VI+b4
6 changed files with 43 additions and 2 deletions

View file

@ -1,4 +1,4 @@
use agahnim_web_v2::templates::index::home; use agahnim_web_v2::templates::{index::home, notfound::notfound};
use axum::{Router, routing::get}; use axum::{Router, routing::get};
use tower_http::services::ServeDir; use tower_http::services::ServeDir;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
@ -8,7 +8,8 @@ use tower_livereload::LiveReloadLayer;
async fn main() { async fn main() {
let app = Router::new() let app = Router::new()
.route("/", get(home)) .route("/", get(home))
.nest_service("/static", ServeDir::new("static")); .nest_service("/static", ServeDir::new("static"))
.fallback(notfound);
// We need to include this flag so that the live reload layer isn't included when the server is built // We need to include this flag so that the live reload layer isn't included when the server is built
#[cfg(debug_assertions)] #[cfg(debug_assertions)]

View file

@ -1 +1,2 @@
pub mod index; pub mod index;
pub mod notfound;

10
src/templates/notfound.rs Normal file
View file

@ -0,0 +1,10 @@
use askama::Template;
use axum::response::{Html, IntoResponse};
#[derive(Template)]
#[template(path = "notfound.html")]
struct NotfoundTemplate;
pub async fn notfound() -> impl IntoResponse {
Html(NotfoundTemplate.render().unwrap())
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

View file

@ -81,3 +81,23 @@ home-content {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
/* 404 */
katcenkat {
display: flex;
flex-direction: column;
flex-wrap: wrap;
justify-content: center;
align-items: center;
img {
transition: opacity 5s ease, transform 5s ease-out;
opacity: 1;
transform: translateY(0px);
@starting-style {
opacity: 0;
transform: translateY(500px);
}
}
}

9
templates/notfound.html Normal file
View file

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block content %}
<katcenkat>
<img src="/static/assets/images/notfound.webp" />
<img src="/static/assets/images/leuf.webp" />
</katcenkat>
{% endblock %}