Serve static files if no other endpoints match
This commit is contained in:
parent
c4f1cd2201
commit
6cf1b662ae
4 changed files with 195 additions and 1 deletions
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue