use axum::{response::Html, routing::get, Router}; use clap::Parser; use dioxus::prelude::*; const LOCALHOST: &str = "127.0.0.1"; #[derive(Parser, Debug)] #[command(version, about, long_about = None)] struct Args { /// Post used #[arg(short, long, default_value_t = 3000)] port: u16, /// IP used #[arg(short, long, default_value_t = LOCALHOST.to_string())] address: String, } #[tokio::main] async fn main() { let args = Args::parse(); let url = format!("{}:{}", args.address, args.port); let app = Router::new().route("/", get(|| app_endpoint())); let listener = tokio::net::TcpListener::bind(&url).await.unwrap(); axum::serve(listener, app).await.unwrap(); } async fn app_endpoint() -> Html { // render the rsx! macro to HTML Html(dioxus_ssr::render_lazy(rsx! { div { "hello world!" } })) }