Spaces:
Build error
Build error
File size: 979 Bytes
365c112 e3036ce 8f15b28 365c112 e3036ce 365c112 e3036ce 8f15b28 e3036ce 365c112 ef98263 8f15b28 365c112 e3036ce 8f15b28 ef98263 8f15b28 e3036ce ef98263 e3036ce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
use axum::{routing::{get, post}, Router};
use tower_http::services::ServeDir;
use std::sync::Arc;
use tokio::sync::broadcast;
mod agent;
mod browser;
mod sse;
mod ui;
pub struct AppState {
pub tx: broadcast::Sender<String>,
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
// Channel for streaming logs and browser frames to UI
let (tx, _) = broadcast::channel(100);
let state = Arc::new(AppState { tx });
let app = Router::new()
.route("/api/chat", post(agent::chat_handler))
.route("/api/stream", get(sse::stream::sse_handler))
// Serve the React frontend from the dist folder
.fallback_service(ServeDir::new("./frontend/dist"))
.with_state(state);
// Axum 0.7 way to start the server
let listener = tokio::net::TcpListener::bind("0.0.0.0:7860").await.unwrap();
println!("π Agent Server running on http://0.0.0.0:7860");
axum::serve(listener, app).await.unwrap();
} |