38-Moths is a web-framework written in C.
More status code headers.
More doc fixes.



You can also use your local clone with git send-email.



Bizarre web framework. Do not be afraid.


You'll need to install some dependencies. Then you can just:

sudo make install


I wanted a minimal, fast webserver/framework thing that I could just install, link with and go. No package management, no weird languages-of-the-week to install, just C. It should be a minimal scaffold to build things off of that I can run in a tmux session ad infinitum. It should have zero dependencies, because its just a webserver. I don't need Boost, a weird allocator, google dependencies or anything else. It's just sockets and bytes and Dennis Ritchie's ghost. It's POSIX.


#include <string.h>

#include <38-moths/38-moths.h>

int main_sock_fd;

static int index_handler(const http_request *request, http_response *response) {
	const unsigned char buf[] = "Hello, World!";
	response->out = malloc(sizeof(buf));
	memcpy(response->out, buf, sizeof(buf));

	response->outsize = sizeof(buf);
	return 200;

static const route all_routes[] = {
	{"GET", "root_handler", "^/$", 0, &index_handler, &heap_cleanup},

int main(int argc, char *argv[]) {
	http_serve(&main_sock_fd, 2, all_routes, sizeof(all_routes)/sizeof(all_routes[0]));
	return 0;

See the examples directory for more, or check out waifu.xyz for a large example.


Currently there are only tests for the GRESHUNKEL templating language. The Makefile spits out a greshunkel_test binary that you can run.