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
# libhttp3
A basic HTTP Framework5
## Installation7
```8
sudo make install9
```11
## Usage13
```c14
#define LIB_HTTP_IMPL15
#include <so/http.h>17
HTTP_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
}25
int 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
```