so://phie

tpee

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

2

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

4

5## Installation

6

7```

8git clone git@soophie.de:/srv/git/tpee

9cd http

10sudo make install

11```

12

13## Quick Start

14

15```c

16#define SO_TPEE_IMPL

17#include <tpee.h>

18

19#define HOST "0.0.0.0"

20#define PORT 80

21

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

30

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

47

48### Compiling

49

50```bash

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

52```