/* { f_front.py [ SEND FROM STATIC DIRECTORY /static/ /favicon.ico /manifest.json /service_worker.json /apple-touch-icon.png ] / /settings /profile/{login} /search// /friends } { f_friends.py /friends/add/ /friends/remove/ /friends/set_relation// } { f_issues.py /addissue// } { f_locations.py /goto/ } { f_users.py /getuser/ /settings/profile [POST] } */ use std::sync::Arc; use axum::Router; use log::info; use tower_http::trace::TraceLayer; use tracing_subscriber::EnvFilter; mod friends; #[derive(Clone, Debug)] struct GlobalState { templates: Arc>, } #[tokio::main] async fn main() { tracing_subscriber::fmt() // This allows you to use, e.g., `RUST_LOG=info` or `RUST_LOG=debug` // when running the app to set log levels. .with_env_filter( EnvFilter::try_from_default_env() .or_else(|_| EnvFilter::try_new("froxy_server=error,tower_http=warn")) .unwrap(), ) .init(); let mut env = minijinja::Environment::new(); froxy_templates::friends::add_to_context(&mut env); let global_state = GlobalState { templates: Arc::new(env), }; let app = Router::new() .merge(friends::router()) .with_state(global_state) .layer(TraceLayer::new_for_http()); let (ip, port) = ("0.0.0.0", 3000); info!("Starting server on {ip}:{port}"); // run our app with hyper, listening globally on port 3000 let listener = tokio::net::TcpListener::bind((ip,port)).await.unwrap(); axum::serve(listener, app).await.unwrap(); }