diff options
| -rw-r--r-- | src/main.zig | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main.zig b/src/main.zig index 65a9f95..b874ddd 100644 --- a/src/main.zig +++ b/src/main.zig @@ -49,7 +49,7 @@ fn handle_request(io: std.Io, stream: std.Io.net.Stream) void { , .{ .status = .ok }) catch break; } - std.debug.print("closing http thread\n", .{}); + // std.debug.print("closing http thread\n", .{}); } pub fn main(init: std.process.Init) !void { @@ -68,7 +68,17 @@ pub fn main(init: std.process.Init) !void { // In order to do I/O operations need an `Io` instance. const io = init.io; - const address = try std.Io.net.IpAddress.parseIp4("0.0.0.0", 1234); + var port: u16 = 10010; + if (init.environ_map.get("PORT")) |s| { + if (std.fmt.parseInt(u16, s, 10)) |p| { + port = p; + } + else |e| { + std.debug.print("{}\n", .{e}); + } + } + + const address = try std.Io.net.IpAddress.parseIp4("0.0.0.0", port); var net_server = try address.listen(io, .{ .reuse_address = true }); while (true) { @@ -76,6 +86,6 @@ pub fn main(init: std.process.Init) !void { _ = io.async(handle_request, .{ io, stream }); - std.debug.print("created http thread\n", .{}); + // std.debug.print("created http thread\n", .{}); } } |
