A basic HTTP Framework
git clone git@soophie.de:/srv/git/so-http
A basic HTTP Framework
git clone git@soophie.de:/srv/git/so/http
cd http
sudo make install
#define SO_HTTP_IMPL
#include <so/http.h>
#define HOST "0.0.0.0"
#define PORT 80
HTTP_GET("/", index_page) {
(void) req;
http_resp_t resp = http_resp_create(HTTP_STATUS_OK);
http_resp_header(&resp, "Content-Type", "text/html");
char *html = "<h1>Hello, World!</h1>";
http_resp_body(&resp, html, strlen(html));
return resp;
}
int main(void) {
http_t *http = http_init();
http_err_t err = http_bind_listen(http, HOST, PORT);
if (err == HTTP_ERR_OK) {
printf("server is running on %s:%d\n", HOST, PORT);
pause();
http_close(http);
}
else {
printf("failed to start server on %s:%d\n", HOST, PORT);
}
printf("server stopped\n");
http_cleanup(http);
return 0;
}
cc -o main -lssl -lcrypto -lpthread main.c
This project is licensed under the GNU General Public License v3.0 (GPLv3).
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.
See the LICENSE file for the full legal text.