hello_world/
hello_world.rs

1//! Run with `cargo run --example hello_world` command.
2//!
3//! To connect through browser, navigate to "http://localhost:3000" url.
4
5use axum::{routing::get, Router};
6use std::net::SocketAddr;
7
8#[tokio::main]
9async fn main() {
10    let app = Router::new().route("/", get(|| async { "Hello, world!" }));
11
12    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
13    println!("listening on {}", addr);
14    axum_server::bind(addr)
15        .serve(app.into_make_service())
16        .await
17        .unwrap();
18}