A low-key HTTP micro-framework for people who hate web bloat
git clone git://soophie.de/tpee
blob: 918c6101b83af8fc61ebc0dadd31e5ccf010d5e7 (959 bytes)[doc][blame][raw]
1
# tpee3
A low-key HTTP micro-framework for people who hate web bloat5
## Installation7
```8
git clone git@soophie.de:/srv/git/tpee9
cd http10
sudo make install11
```13
## Quick Start15
```c16
#define SO_TPEE_IMPL17
#include <tpee.h>19
#define HOST "0.0.0.0"20
#define PORT 8022
TPEE_GET("/", index_page) {23
(void) req;24
tpee_resp_t resp = tpee_resp_create(TPEE_STATUS_OK);25
tpee_resp_header(&resp, "Content-Type", "text/html");26
char *html = "<h1>Hello, World!</h1>";27
tpee_resp_body(&resp, html, strlen(html));28
return resp;29
}31
int main(void) {32
tpee_t *tpee = tpee_init();33
tpee_err_t err = tpee_bind_listen(tpee, HOST, PORT);34
if (err == tpee_ERR_OK) {35
printf("server is running on %s:%d\n", HOST, PORT);36
pause();37
tpee_close(tpee);38
}39
else {40
printf("failed to start server on %s:%d\n", HOST, PORT);41
}42
printf("server stopped\n");43
tpee_cleanup(tpee);44
return 0;45
}46
```48
### Compiling50
```bash51
cc -o main -lssl -lcrypto -lpthread main.c52
```