This commit is contained in:
Zengtudor 2024-07-11 16:34:20 +08:00
parent 911ea21c75
commit 94f9cb06ec
2 changed files with 21 additions and 3 deletions

View File

@ -4,3 +4,6 @@ version = "0.1.0"
edition = "2021"
[dependencies]
axum = "0.7.5"
serde = "1.0.204"
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }

View File

@ -1,3 +1,18 @@
fn main() {
println!("Hello, world!");
}
use axum::{
routing::get,
Router,
};
#[tokio::main]
async fn main() {
// build our application with a single route
let app = Router::new().route("/", get(|| async { "Hello, World!" }));
// run our app with hyper, listening globally on port 3000
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
println!("The rust Server is running on http://127.0.0.1:3000");
axum::serve(listener, app).await.unwrap();
}