This repository has been archived on 2024-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
staxman-old/src/main.rs

28 lines
560 B
Rust
Raw Normal View History

2023-11-18 13:29:19 +00:00
use std::net::SocketAddr;
2023-11-18 11:35:40 +00:00
2023-11-18 13:29:19 +00:00
use askama_axum::Template;
use axum::{routing::get, Router};
#[derive(Template)]
#[template(path = "hello.html")]
struct HelloTemplate {}
async fn hello() -> HelloTemplate {
HelloTemplate {}
2023-11-18 11:35:40 +00:00
}
#[tokio::main]
async fn main() {
2023-11-18 13:29:19 +00:00
tracing_subscriber::fmt::init();
2023-11-18 11:35:40 +00:00
2023-11-18 13:29:19 +00:00
let app = Router::new().route("/", get(hello));
2023-11-18 11:35:40 +00:00
2023-11-18 13:29:19 +00:00
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
tracing::info!("listening on {}", addr);
2023-11-18 11:35:40 +00:00
2023-11-18 13:29:19 +00:00
axum::Server::bind(&addr)
2023-11-18 11:35:40 +00:00
.serve(app.into_make_service())
.await
.unwrap();
}