axum web app
This commit is contained in:
parent
07205c41de
commit
7cc91285a0
1 changed files with 13 additions and 2 deletions
15
src/main.rs
15
src/main.rs
|
|
@ -1,3 +1,14 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use axum::{response::Html, routing::get, Router};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let app = Router::new().route("/", get(handler));
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3001").await.unwrap();
|
||||
println!("listening on {}", listener.local_addr().unwrap());
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
|
||||
async fn handler() -> Html<&'static str> {
|
||||
Html("<h1>Hello, World!</h1>")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue