use axum::{ response::{Html, IntoResponse}, routing::get, Router, }; use tokio::net::TcpListener; #[tokio::main] async fn main() -> Result<(), String> { let app = create_routes().await; let bind_addr = &"0.0.0.0:2900"; let listener = TcpListener::bind(bind_addr) .await .map_err(|e| format!("Failed to parse address: {}", e))?; axum::serve(listener, app.into_make_service()) .await .map_err(|e| format!("Server error: {}", e))?; Ok(()) } pub async fn create_routes() -> Router { Router::new() .route("/", get(index)) .route("/some", get(some)) } pub async fn index() -> impl IntoResponse { let content = r#"
The hard way: {}
The easy way: {}
"#, hard, easy ); Html(content) }