From 7e896c1397a6d2ccbac31a63852b6ed0fbd32a8d Mon Sep 17 00:00:00 2001 From: gyoder <70408179+gyoder@users.noreply.github.com> Date: Sat, 5 Jul 2025 16:13:17 -0600 Subject: added apache2 cgi script --- htmlua-apache-cgi/Cargo.toml | 8 ++++++++ htmlua-apache-cgi/src/main.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 htmlua-apache-cgi/Cargo.toml create mode 100644 htmlua-apache-cgi/src/main.rs (limited to 'htmlua-apache-cgi') diff --git a/htmlua-apache-cgi/Cargo.toml b/htmlua-apache-cgi/Cargo.toml new file mode 100644 index 0000000..7a8052d --- /dev/null +++ b/htmlua-apache-cgi/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "htmlua-apache-cgi" +version = "0.1.0" +edition = "2024" + +[dependencies] +htmlua-parser = { path = "../htmlua-parser" } +kuchikiki = "0.8.2" diff --git a/htmlua-apache-cgi/src/main.rs b/htmlua-apache-cgi/src/main.rs new file mode 100644 index 0000000..ce86dc6 --- /dev/null +++ b/htmlua-apache-cgi/src/main.rs @@ -0,0 +1,32 @@ +use std::env; +use std::fs; +use std::fs::read_to_string; +use std::path::{Path, PathBuf}; +use std::str::FromStr; +use htmlua_parser::serve::serve_content; +use kuchikiki::{ + NodeRef, + traits::TendrilSink, +}; + +fn main() { + println!("Content-Type: text/html\n"); + + let request_uri = env::var("PATH_INFO").unwrap_or_else(|_| "".to_string()); + + let page = serve_content(request_uri.as_str()).unwrap(); + + + // Output the final expanded HTML + println!("{page}"); +} + +// Simple HTML escape function +fn html_escape(input: &str) -> String { + input + .replace('&', "&") + .replace('<', "<") + .replace('>', ">") + .replace('"', """) + .replace('\'', "'") +} -- cgit v1.3.1