const std = @import("std"); const http = @import("http"); //const db = @import("./db.zig"); pub fn main() anyerror!void { var srv = try http.Server.listen(std.net.Address.parseIp("0.0.0.0", 8080) catch unreachable); defer srv.shutdown(); while (true) { var buf: [1 << 20]u8 = undefined; var fba = std.heap.FixedBufferAllocator.init(&buf); const alloc = fba.allocator(); var ctx = try srv.accept(alloc); defer ctx.close(); const headers = http.Headers.init(alloc); var stream = try ctx.openResponse(&headers, .ok); const writer = stream.writer(); defer stream.close(); try writer.print("Page for {s}", .{ctx.request.path}); try stream.finish(); } }