Set up basic axum server

This commit is contained in:
Joscha 2024-04-30 23:01:45 +02:00
parent b4c5591a60
commit e9705e5c5c
5 changed files with 975 additions and 0 deletions

23
src/main.rs Normal file
View file

@ -0,0 +1,23 @@
use axum::{routing::get, Router};
use clap::Parser;
use tokio::net::TcpListener;
#[derive(Parser)]
struct Args {
addr: String,
}
async fn root() -> &'static str {
"Hello world!"
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let args = Args::parse();
let app = Router::<()>::new().route("/", get(root));
let listener = TcpListener::bind(args.addr).await?;
axum::serve(listener, app).await?;
Ok(())
}