so://phie

tpee

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# tpee

2

3A low-key HTTP micro-framework for people who hate web bloat

4

5## Quick Start

6

7```c

8#define SO_TPEE_IMPL

9#include <tpee.h>

10

11#define HOST "0.0.0.0"

12#define PORT 80

13

14TPEE_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}

22

23int 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```

39

40### Compiling

41

42```bash

43cc -o main -lssl -lcrypto -lpthread main.c

44```