Add static endpoint
This commit is contained in:
@@ -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}");
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user