aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2023-08-21 22:10:31 +0100
committerMartin Ashby <martin@ashbysoft.com>2023-08-21 22:10:31 +0100
commit34a423c3608b2ec2c852986350152cb6c38ba4be (patch)
tree8f671160db1b61ca00cd923ce52a20d948c79da2 /src
downloadcgifun-34a423c3608b2ec2c852986350152cb6c38ba4be.tar.gz
cgifun-34a423c3608b2ec2c852986350152cb6c38ba4be.tar.bz2
cgifun-34a423c3608b2ec2c852986350152cb6c38ba4be.tar.xz
cgifun-34a423c3608b2ec2c852986350152cb6c38ba4be.zip
initialHEADmain
Diffstat (limited to 'src')
-rw-r--r--src/main.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
new file mode 100644
index 0000000..e4fab76
--- /dev/null
+++ b/src/main.zig
@@ -0,0 +1,27 @@
+const std = @import("std");
+
+/// Produces an HTML page listing the environment variables.
+pub fn main() !void {
+ const stdout = std.io.getStdOut().writer();
+ //
+ try stdout.writeAll("Content-Type: text/html\r\n");
+ try stdout.writeAll("\r\n");
+ try stdout.writeAll(
+ \\<!doctype HTML>
+ \\<html>
+ \\<body>
+ \\<p>Environment variables passed to CGI script:</p>
+ \\<ul>
+ );
+ for (std.os.environ) |env| {
+ try stdout.writeAll("<li>");
+ const env_slice = std.mem.sliceTo(env, 0);
+ try stdout.writeAll(env_slice);
+ try stdout.writeAll("</li>\n");
+ }
+ try stdout.writeAll(
+ \\</ul>
+ \\</body>
+ \\</html>
+ );
+}