Advertisement
Guest User

Untitled

a guest
Jun 30th, 2021
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. const std = @import("std");
  2. const web = @import("./zhp/src/zhp.zig");
  3.  
  4. pub const io_mode = .evented;
  5. pub const log_level = .info;
  6.  
  7. const MainHandler = struct {
  8. pub fn get(self: *MainHandler, request: *web.Request, response: *web.Response) !void {
  9. _ = try response.stream.write("HelloWorld!");
  10. }
  11. };
  12.  
  13. pub const routes = [_]web.Route{
  14. web.Route.create("home", "/", MainHandler),
  15. };
  16.  
  17. pub fn main() anyerror!void {
  18. var allocator = std.heap.raw_c_allocator;
  19.  
  20. var app = web.Application.init(allocator, .{ .debug = false });
  21. defer app.deinit();
  22.  
  23. try app.listen("127.0.0.1", 9000);
  24. try app.start();
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement