Serve static files if no other endpoints match

This commit is contained in:
Joscha 2023-08-03 17:36:27 +02:00
parent c4f1cd2201
commit 6cf1b662ae
4 changed files with 195 additions and 1 deletions

View file

@ -1,7 +1,11 @@
mod r#static;
use axum::{routing::get, Router};
async fn run() -> anyhow::Result<()> {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let app = Router::new()
.route("/", get(|| async { "Hello, world!" }))
.fallback(get(r#static::static_handler));
axum::Server::bind(&"0.0.0.0:8000".parse().unwrap())
.serve(app.into_make_service())