diff options
| author | Ibrahim Muftee <ibrahim@muftee.net> | 2026-08-22 06:15:11 +0000 |
|---|---|---|
| committer | Ibrahim Muftee <ibrahim@muftee.net> | 2026-08-22 06:15:11 +0000 |
| commit | 4c10c51e55226dc7321e0ae5d6bf692ca70af9a7 (patch) | |
| tree | 9ca48009881f7023561d38e4acf08bf1ed4a8b9e | |
| parent | eb07b4c3863f3aa6ee8cf0036da9fbf75a08bde8 (diff) | |
| -rw-r--r-- | http.zig | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -9,6 +9,7 @@ const MAX_BUF = 1024; const Endpoint = enum { root_get, login_get, + create_account_get, }; pub fn serve(io: std.Io, address: []const u8, port: u16) !void { @@ -57,6 +58,8 @@ fn endpointFromRequest(request: *Request) !Endpoint { return .root_get; } else if (head.method == .GET and std.mem.eql(u8, head.target, "/login")) { return .login_get; + } else if (head.method == .GET and std.mem.eql(u8, head.target, "/create-account")) { + return .create_account_get; } return error.InvalidEndpoint; } @@ -71,6 +74,7 @@ fn serveHTTP(request: *Request) !void { switch (endpoint) { .root_get => try handleRoot(request), .login_get => try handleLogin(request), + .create_account_get => try handleCreateAccountGet(request), } } @@ -85,3 +89,41 @@ fn handleRoot(request: *Request) !void { fn handleLogin(request: *Request) !void { try request.respond("Login page\n", .{}); } + +fn handleCreateAccountGet(request: *Request) !void { + try request.respond( + \\<!DOCTYPE html> + \\<html> + \\ <head> + \\ <meta charset="utf-8"> + \\ <meta name="viewport" content="width=device-width, inital-scale=1"> + \\ <title>Coinvane</title> + \\ <style type="text/css"> + \\ body{ + \\ margin: 40px auto; + \\ max-width: 650px; + \\ line-height: 1.6; + \\ font-size: 18px; + \\ color: #444; + \\ padding: 0 10px + \\ } + \\ h1,h2,h3{ + \\ line-height: 1.2 + \\ } + \\ </style> + \\ </head> + \\ <body> + \\ <header> + \\ <h1>Create Account</h1> + \\ </header> + \\ <form action="/create-account" method="POST"> + \\ <label for="email">Email:</label> + \\ <input type="email" id="email" name="email" required> + \\ <label for="password">Password:</label> + \\ <input type="password" id="password" name="password required> + \\ <input type="submit" value="Submit"> + \\ </form> + \\ </body> + \\</html> + , .{}); +} |
