Gave the app the ability to change ports.

This commit is contained in:
2024-02-29 11:20:20 -05:00
parent affc00fa02
commit 6b68a0d186
6 changed files with 2173 additions and 12 deletions

View File

@ -1,3 +1,27 @@
fn main() {
println!("Hello, world!");
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!" }
}))
}