2024-02-29 11:20:20 -05:00
|
|
|
use axum::{response::Html, routing::get, Router};
|
|
|
|
use clap::Parser;
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
#[command(version, about, long_about = None)]
|
|
|
|
struct Args {
|
|
|
|
/// Post used
|
|
|
|
#[arg(short, long, default_value_t = 3000)]
|
|
|
|
port: u16
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() {
|
|
|
|
let args = Args::parse();
|
|
|
|
let url = format!("127.0.0.1:{}", 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<String> {
|
|
|
|
// render the rsx! macro to HTML
|
|
|
|
Html(dioxus_ssr::render_lazy(rsx! {
|
|
|
|
div { "hello world!" }
|
|
|
|
}))
|
2024-02-26 08:41:24 -05:00
|
|
|
}
|