Create stub Axum app

This commit is contained in:
Matthew Gordon 2024-02-10 12:57:20 -04:00
parent 02af71212e
commit 70842b1db2
2 changed files with 24 additions and 0 deletions

10
Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "localhub"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "1", features = ["rt-multi-thread"]}
axum = "0.7"

14
src/main.rs Normal file
View File

@ -0,0 +1,14 @@
use axum::{routing::get, Router};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = Router::new().route("/", get(root));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
axum::serve(listener, app).await?;
Ok(())
}
async fn root() -> &'static str {
"It works!"
}