chore: add live reload features

This commit is contained in:
Alexander Navarro 2025-02-13 13:03:39 -03:00
parent 0923ac1841
commit b6c909f6f4
4 changed files with 184 additions and 5 deletions

View file

@ -1,9 +1,14 @@
use axum::response::Html;
use axum::routing::get;
use axum::Router;
#[tokio::main]
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, World!" }));
let app = Router::new().route("/", get(|| async { Html("<h1>Hello, World! 2</h1>") }));
// Add hot reload only on dev mode
#[cfg(debug_assertions)]
let app = app.layer(tower_livereload::LiveReloadLayer::new());
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();