Add static endpoint

This commit is contained in:
2026-01-12 22:45:41 +02:00
parent d6be7111f9
commit 5cea377934
7 changed files with 393 additions and 1 deletions

View File

@@ -1,4 +1,6 @@
use axum::{Router, routing::get};
use tower::ServiceBuilder;
use tower_http::services::ServeDir;
pub mod pages;
@@ -8,7 +10,12 @@ pub mod pages;
pub async fn start() -> anyhow::Result<()> {
let addr = "0.0.0.0:3000";
let app = Router::new()
.route("/", get(pages::home::get_page));
.route("/", get(pages::home::get_page))
.nest_service(
"/static",
ServiceBuilder::new()
.service(ServeDir::new("static"))
);
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
log::info!("Listening on http://{addr}");

View File

@@ -40,6 +40,7 @@ pub async fn get_page() -> Response {
Ok((StatusCode::OK, template.render()?))
}
match inner() {
Ok((status, s)) => (status, Html(s)).into_response(),
Err(e) => {