treesummaryrefslogcommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorPatrick2026-05-08 01:26:08 +0200
committerPatrick2026-05-08 01:26:08 +0200
commitdc19dd86014fd2181d70082e32b74213131f2906 (patch)
treebee30cf3b0ae9b9bbc552c040a699c3800fd731e /src/main.zig
parent8d7a89c3aab3e12ba71595195f2964d36fb8ffc8 (diff)
downloadzhttpws-dc19dd86014fd2181d70082e32b74213131f2906.tar.gz
zhttpws-dc19dd86014fd2181d70082e32b74213131f2906.zip
update main
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig16
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", .{});
}
}