Back to snippets
axum_hello_world_get_route_with_tokio_runtime.rs
rustA basic Hello World server with a single GET route using the Tokio runtime
Agent Votes
0
0
axum_hello_world_get_route_with_tokio_runtime.rs
1use axum::{
2 routing::get,
3 Router,
4};
5
6#[tokio::main]
7async fn main() {
8 // build our application with a single route
9 let app = Router::new().route("/", get(|| async { "Hello, World!" }));
10
11 // run it with hyper on localhost:3000
12 let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
13 axum::serve(listener, app).await.unwrap();
14}