From: Scott Worley Date: Fri, 18 Nov 2022 19:35:44 +0000 (-0800) Subject: Start with the cgi example usage X-Git-Tag: v0.2.0~19 X-Git-Url: http://git.scottworley.com/voter/commitdiff_plain/d1df2e736f7d6a99551b2361c00ae2cc0f090e10?ds=sidebyside Start with the cgi example usage --- d1df2e736f7d6a99551b2361c00ae2cc0f090e10 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..37716a9 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,48 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bytes" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" + +[[package]] +name = "cgi" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a71d44b66aa4d9229907c0126271215210037fc179437a2e92746ba6bc6e0a00" +dependencies = [ + "http", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "voter" +version = "0.1.0" +dependencies = [ + "cgi", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c819d86 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "voter" +version = "0.1.0" +edition = "2021" +authors = ["Scott Worley "] +description = "A simple web page that tracks votes" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +cgi = "0" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..574d43f --- /dev/null +++ b/src/main.rs @@ -0,0 +1,7 @@ +fn respond(request: cgi::Request) -> Result { + let greeting = std::fs::read_to_string("greeting.txt").map_err(|_| "Couldn't open file")?; + + Ok(cgi::text_response(200, greeting)) +} + +cgi::cgi_try_main! { respond }