diff options
author | Martin Ashby <martin@ashbysoft.com> | 2023-08-21 22:10:31 +0100 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2023-08-21 22:10:31 +0100 |
commit | 34a423c3608b2ec2c852986350152cb6c38ba4be (patch) | |
tree | 8f671160db1b61ca00cd923ce52a20d948c79da2 /src/main.zig | |
download | cgifun-main.tar.gz cgifun-main.tar.bz2 cgifun-main.tar.xz cgifun-main.zip |
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 27 |
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> + ); +} |