add static files support; basic css
This commit is contained in:
parent
4f9d7ce833
commit
cac77accd1
5 changed files with 74 additions and 0 deletions
|
@ -3,6 +3,7 @@ use std::sync::Arc;
|
|||
use axum::{extract::State, http::StatusCode, response::IntoResponse, routing::get, Router};
|
||||
use data::Data;
|
||||
use maud::Markup;
|
||||
use tower_http::services::ServeDir;
|
||||
|
||||
pub mod clock;
|
||||
pub mod data;
|
||||
|
@ -43,6 +44,7 @@ async fn main_handler(state: State<Arc<AppState>>) -> Result<Markup, AppError> {
|
|||
async fn main() {
|
||||
let app = Router::new()
|
||||
.route("/", get(main_handler))
|
||||
.nest_service("/static", ServeDir::new("static"))
|
||||
.with_state(Arc::new(AppState { data: Data::new() }));
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||
println!("Listening on http://localhost:3000!");
|
||||
|
|
|
@ -16,6 +16,7 @@ pub fn layout(content: Markup) -> Markup {
|
|||
head {
|
||||
title { "beacon" }
|
||||
meta name="viewport" content="width=device-width";
|
||||
link rel="stylesheet" href="/static/style.css";
|
||||
}
|
||||
|
||||
body { (content) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue