- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
Latest commit
20 lines (15 loc) · 502 Bytes
/
Copy pathmain.cpp
File metadata and controls
20 lines (15 loc) · 502 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include"beriw-lib/http_server.h"
#include<iostream>
voidhelloHandler(const std::map<std::string, std::string>& params, std::string& response) {
// Bangun respons JSON
response = "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n";
response += "{ \"message\": \"Hello, World!\" }";
}
intmain() {
HTTPServer server;
// Tambahkan rute dan handler
server.addRoute("/hello", helloHandler);
// Mulai server pada port 8080
server.start(8080);
return0;
}