add comments, serve static crap

This commit is contained in:
xomf 2024-03-23 16:19:00 -04:00
parent d22d3a71c8
commit f835c26f03
3 changed files with 40 additions and 1 deletions

36
Cargo.lock generated
View File

@ -19,6 +19,29 @@ dependencies = [
"tracing", "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]] [[package]]
name = "actix-http" name = "actix-http"
version = "3.6.0" version = "3.6.0"
@ -696,6 +719,12 @@ dependencies = [
"itoa", "itoa",
] ]
[[package]]
name = "http-range"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573"
[[package]] [[package]]
name = "httparse" name = "httparse"
version = "1.8.0" version = "1.8.0"
@ -967,6 +996,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
name = "personal-website" name = "personal-website"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"actix-files",
"actix-web", "actix-web",
"actix-web-lab", "actix-web-lab",
"anyhow", "anyhow",
@ -1449,6 +1479,12 @@ dependencies = [
"percent-encoding", "percent-encoding",
] ]
[[package]]
name = "v_htmlescape"
version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"

View File

@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
actix-files = "0.6.5"
actix-web = "4.5.1" actix-web = "4.5.1"
actix-web-lab = "0.20.2" actix-web-lab = "0.20.2"
anyhow = "1.0.81" anyhow = "1.0.81"

View File

@ -3,12 +3,14 @@ mod routes;
mod templates; mod templates;
use actix_web::{web, App, HttpServer}; use actix_web::{web, App, HttpServer};
use actix_files as actix_fs;
pub(crate) async fn start_actix() -> anyhow::Result<()> { pub(crate) async fn start_actix() -> anyhow::Result<()> {
log::info!("Serving an http server at http://0.0.0.0:8080"); log::info!("Serving an http server at http://0.0.0.0:8080");
HttpServer::new(|| { HttpServer::new(|| {
App::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("0.0.0.0:8080")? .bind("0.0.0.0:8080")?