aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
blob: e4fab76602ef11ebb48e3edddecd786a9080e0ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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>
    );
}