-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
34 lines (30 loc) · 1.04 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "object.h"
#include "modules/threadpoolobject.h"
#include "modules/httpheaderobject.h"
#include "modules/httprequestobject.h"
#include "modules/httpserverobject.h"
#include "modules/httphandlerobject.h"
int main(int argc, char *args[]) {
Object *size = IntObject_FromInt(2);
Object *url_handler = Object_NULL;
Object *url = Object_NULL;
Object *handler = Object_NULL;
url_handler = ListObject_New(size);
Object_DECREF(size);
url = StrObject_FromStr("/user");
Object_CallMethod(url_handler, "Append", url);
Object_DECREF(url);
handler = HttpHandlerObject_New();
Object_CallMethod(url_handler, "Append", handler);
Object_DECREF(handler);
Object *ip = StrObject_FromStr("0.0.0.0");
Object *port = IntObject_FromInt(1024);
Object *server = HttpServerObject_New(ip, port);
Object_CallMethod(server, "AddHandler", url_handler);
Object_CallMethod(server, "Start", port);
Object_DECREF(ip);
Object_DECREF(port);
Object_DECREF(server);
Object_DECREF(url_handler);
return 0;
}