From 523e2b9df9b9f8557ae8044f1e66af16273eddf9 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sun, 29 Oct 2023 22:36:38 -0400 Subject: [PATCH] Server improvements --- index.html | 2 +- run.sh | 2 +- src/api/get_args.rs | 3 +++ src/bin/backend.rs | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 10fea4f..e4e2f2d 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ Yarrr - + diff --git a/run.sh b/run.sh index 1654ffb..6bf213d 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,4 @@ #!/bin/bash #trunk build ./index.html && cargo run --bin backend -- localhost:7534 -trunk build ./index.html && cargo run --bin backend -- localhost:7534 --dir /mnt/nas/media -u user -p password +trunk build ./index.html && cargo run --bin backend -- localhost:7534 --dir /mnt/nas/media -u user -p password --port 7534 diff --git a/src/api/get_args.rs b/src/api/get_args.rs index 0907733..d4c8698 100644 --- a/src/api/get_args.rs +++ b/src/api/get_args.rs @@ -23,6 +23,9 @@ pub struct CliArgs { /// Display hidden files #[clap(short, long)] pub hidden: bool, + /// Local network port + #[clap(long)] + pub port: u16, } impl CliArgs { diff --git a/src/bin/backend.rs b/src/bin/backend.rs index 250305b..9c85dab 100644 --- a/src/bin/backend.rs +++ b/src/bin/backend.rs @@ -26,7 +26,7 @@ async fn main() -> std::io::Result<()> { .service(dir) .service(file) }) - .bind(("127.0.0.1", 7534))? + .bind(("127.0.0.1", args.port))? .run() .await } else { @@ -39,7 +39,7 @@ async fn main() -> std::io::Result<()> { .service(dir) .service(file) }) - .bind(("127.0.0.1", 7534))? + .bind(("127.0.0.1", args.port))? .run() .await }