aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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>
+ );
+}