mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-18 14:48:26 +00:00
30 lines
641 B
Rust
30 lines
641 B
Rust
use axum::Router;
|
|
use dioxus::prelude::*;
|
|
use dioxus_liveview::LiveviewRouter;
|
|
|
|
fn app() -> Element {
|
|
let mut num = use_signal(|| 0);
|
|
|
|
rsx! {
|
|
div {
|
|
"hello axum! {num}"
|
|
button { onclick: move |_| num += 1, "Increment" }
|
|
}
|
|
}
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
pretty_env_logger::init();
|
|
|
|
let addr: std::net::SocketAddr = ([127, 0, 0, 1], 3030).into();
|
|
|
|
let app = Router::new().with_app("/", app);
|
|
|
|
println!("Listening on http://{addr}");
|
|
|
|
axum::Server::bind(&addr.to_string().parse().unwrap())
|
|
.serve(app.into_make_service())
|
|
.await
|
|
.unwrap();
|
|
}
|