Gave the app the ability to change ports.
This commit is contained in:
28
src/main.rs
28
src/main.rs
@ -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!" }
|
||||
}))
|
||||
}
|
||||
|
Reference in New Issue
Block a user