A low-key HTTP micro-framework for people who hate web bloat
git clone git://soophie.de/tpee
blob: 2393529d222f66ba980b930ca01f1fc8a55fb66f (868 bytes)[doc][blame][raw]
1
# tpee3
A low-key HTTP micro-framework for people who hate web bloat5
## Quick Start7
```c8
#define SO_TPEE_IMPL9
#include <tpee.h>11
#define HOST "0.0.0.0"12
#define PORT 8014
TPEE_GET("/", index_page) {15
(void) req;16
tpee_resp_t resp = tpee_resp_create(TPEE_STATUS_OK);17
tpee_resp_header(&resp, "Content-Type", "text/html");18
char *html = "<h1>Hello, World!</h1>";19
tpee_resp_body(&resp, html, strlen(html));20
return resp;21
}23
int main(void) {24
tpee_t *tpee = tpee_init();25
tpee_err_t err = tpee_bind_listen(tpee, HOST, PORT);26
if (err == TPEE_ERR_OK) {27
printf("server is running on %s:%d\n", HOST, PORT);28
pause();29
tpee_close(tpee);30
}31
else {32
printf("failed to start server on %s:%d\n", HOST, PORT);33
}34
printf("server stopped\n");35
tpee_cleanup(tpee);36
return 0;37
}38
```40
### Compiling42
```bash43
cc -o main -lssl -lcrypto -lpthread main.c44
```