# pico-http A minimal HTTP server in C, with the hashtable and linked-list libraries it is built on. ## Layout ``` http/ server and routing framework hashtable/ route table llist/ bucket chaining for the hashtable ``` ## Build Needs `gcc` and `make`. ```sh cd http && make ``` ## Run ```sh ./pico-http ``` Listens on port 3000, set by `PORT` in `http/http.h`. ```sh $ curl localhost:3000/login Login works! $ curl localhost:3000/signup Sign Up works! ``` Unregistered paths return `400 Bad request`. ## Adding a route A handler fills in `Res`: ```c void hello(Req* req, Res* res) { char* content = "Hello\n"; res->status = 200; res->content_type = "text/html"; res->content_length = strlen(content); res->body = content; } ``` Register it before starting the server, in `main.c`: ```c use("/hello", &hello); http_start(PORT); ``` Paths match exactly — `/hello` will not match `/hello/`. ## Library tests ```sh cd llist && make && ./test cd hashtable && make && ./test ``` `make clean` in any of the three directories removes its objects and binary.