Serve new UI from axum server

This commit is contained in:
Joscha 2025-03-03 19:36:32 +01:00
parent 5e60dd2e30
commit 38994a86ae
6 changed files with 51 additions and 69 deletions

View file

@ -12,8 +12,6 @@ use tokio::{net::TcpListener, sync::mpsc};
use crate::{documents, drawer::Command};
use self::r#static::get_static_file;
#[derive(Clone)]
pub struct Server {
tx: mpsc::Sender<Command>,
@ -27,6 +25,12 @@ impl Server {
pub async fn run(tx: mpsc::Sender<Command>, addr: String) -> anyhow::Result<()> {
let app = Router::new()
// Files
.route("/", get(r#static::get_index))
.route("/assets/{*path}", get(r#static::get_asset))
.route("/fonts/{*path}", get(r#static::get_font))
.route("/photo.html", get(r#static::get_photo))
// API
.route("/api/calendar", post(documents::calendar::post))
.route("/api/cells", post(documents::cells::post))
.route("/api/chat", post(documents::chat::post))
@ -34,7 +38,7 @@ pub async fn run(tx: mpsc::Sender<Command>, addr: String) -> anyhow::Result<()>
.route("/api/image", post(documents::image::post))
.route("/api/text", post(documents::text::post))
.route("/api/tictactoe", post(documents::tictactoe::post))
.fallback(get(get_static_file))
// Rest
.layer(DefaultBodyLimit::max(32 * 1024 * 1024)) // 32 MiB
.with_state(Server { tx });