so://phie

tpee

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

blob: e3558bae24e83adf9f12d47581bb3d932fb10092 (1332 bytes)[doc][blame][raw]

1# so/http

2

3A basic HTTP Framework

4

5## Installation

6

7```

8git clone git@soophie.de:/srv/git/so/http

9cd http

10sudo make install

11```

12

13## Quick Start

14

15```c

16#define SO_HTTP_IMPL

17#include <so/http.h>

18

19#define HOST "0.0.0.0"

20#define PORT 80

21

22HTTP_GET("/", index_page) {

23 (void) req;

24 http_resp_t resp = http_resp_create(HTTP_STATUS_OK);

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

26 char *html = "<h1>Hello, World!</h1>";

27 http_resp_body(&resp, html, strlen(html));

28 return resp;

29}

30

31int main(void) {

32 http_t *http = http_init();

33 http_err_t err = http_bind_listen(http, HOST, PORT);

34 if (err == HTTP_ERR_OK) {

35 printf("server is running on %s:%d\n", HOST, PORT);

36 pause();

37 http_close(http);

38 }

39 else {

40 printf("failed to start server on %s:%d\n", HOST, PORT);

41 }

42 printf("server stopped\n");

43 http_cleanup(http);

44 return 0;

45}

46```

47

48### Compiling

49

50```bash

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

52```

53

54## License

55

56This project is licensed under the **GNU General Public License v3.0 (GPLv3)**.

57

58**What this means:** You are free to use, study, and modify this framework. However, if you distribute a program that uses this framework (including selling it), you **must** provide the full source code of your program under the same GPLv3 license.

59

60See the [LICENSE](LICENSE) file for the full legal text.