so://phie

tpee

A low-key HTTP micro-framework for people who hate web bloat
git clone git://soophie.de/tpee

blob: 9c48285cf047326a4612311547b15c6c214e8c8a (754 bytes)[doc][blame][raw]

1# libhttp

2

3A basic HTTP Framework

4

5## Installation

6

7```

8sudo make install

9```

10

11## Usage

12

13```c

14#define LIB_HTTP_IMPL

15#include <so/http.h>

16

17HTTP_GET("/", index_page) {

18 (void) req;

19 http_resp_t resp = http_resp_create(HTTP_STATUS_OK);

20 http_resp_header(&resp, "Content-Type", "text/html");

21 http_resp_body(&resp, "<h1>Hello, World!</h1>", 22);

22 return resp;

23}

24

25int main(void) {

26 http_t *http = http_init();

27 if (http_bind(http, "0.0.0.0", 80, NULL, 0) != HTTP_ERR_OK) {

28 printf("failed to bind port :80\n");

29 http_cleanup(http);

30 return 1;

31 }

32 if (http_listen(http) == HTTP_ERR_OK) {

33 printf("server is running on port :80\n");

34 pause();

35 }

36 http_close(http);

37 printf("server stopped\n");

38 http_cleanup(http);

39 return 0;

40}

41```