morethantext/src/main.rs

33 lines
867 B
Rust
Raw Normal View History

use axum::{response::Html, routing::get, Router};
use clap::Parser;
use dioxus::prelude::*;
2024-02-29 18:46:01 -05:00
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)]
2024-02-29 18:46:01 -05:00
port: u16,
/// IP used
#[arg(short, long, default_value_t = LOCALHOST.to_string())]
address: String,
}
#[tokio::main]
async fn main() {
let args = Args::parse();
2024-02-29 18:46:01 -05:00
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<String> {
2024-03-04 11:21:42 -05:00
// render the rsx! macro to HTML
Html(dioxus_ssr::render_lazy(rsx! {
div { "hello world!" }
}))
2024-02-26 08:41:24 -05:00
}