Merge remote-tracking branch 'origin/main'

fixed confilcting args -h (--host) and -h (--help)
This commit is contained in:
Gvidas Juknevičius 2024-03-23 22:31:40 +02:00
commit a4a1e93ddd
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
4 changed files with 41 additions and 2 deletions

36
Cargo.lock generated
View File

@ -19,6 +19,29 @@ dependencies = [
"tracing",
]
[[package]]
name = "actix-files"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf0bdd6ff79de7c9a021f5d9ea79ce23e108d8bfc9b49b5b4a2cf6fad5a35212"
dependencies = [
"actix-http",
"actix-service",
"actix-utils",
"actix-web",
"bitflags 2.5.0",
"bytes",
"derive_more",
"futures-core",
"http-range",
"log",
"mime",
"mime_guess",
"percent-encoding",
"pin-project-lite",
"v_htmlescape",
]
[[package]]
name = "actix-http"
version = "3.6.0"
@ -796,6 +819,12 @@ dependencies = [
"itoa",
]
[[package]]
name = "http-range"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573"
[[package]]
name = "httparse"
version = "1.8.0"
@ -1067,6 +1096,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
name = "personal-website"
version = "0.1.0"
dependencies = [
"actix-files",
"actix-web",
"actix-web-lab",
"anyhow",
@ -1562,6 +1592,12 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "v_htmlescape"
version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c"
[[package]]
name = "version_check"
version = "0.9.4"

View File

@ -8,6 +8,7 @@ authors = [
]
[dependencies]
actix-files = "0.6.5"
actix-web = "4.5.1"
actix-web-lab = "0.20.2"
anyhow = "1.0.81"

View File

@ -9,7 +9,7 @@ pub struct CliArgs {
pub port: u16,
/// Host ip to bind to, usually not required to change
#[arg(short, long, default_value="0.0.0.0")]
#[arg(long, default_value="0.0.0.0")]
pub host: String,
/// Extra debugging output

View File

@ -3,6 +3,7 @@ mod routes;
mod templates;
use actix_web::{web, App, HttpServer};
use actix_files as actix_fs;
use crate::cli::CliArgs;
@ -12,7 +13,8 @@ pub(crate) async fn start_actix(cli: &CliArgs) -> anyhow::Result<()> {
log::info!("Serving an http server at http://{bindip}");
HttpServer::new(|| {
App::new()
.route("/", web::get().to(routes::index))
.route("/", web::get().to(routes::index)) // index.html
.service(actix_fs::Files::new("/static", "./static").index_file("index.html")) // static directoryh
})
.bind(bindip)?