2023

C Web Server

I wrote this C web server for an earlier version of my personal site because I wanted to understand what happens underneath a web framework. It opens a listening socket, reads simple GET requests, maps request paths to files, chooses a MIME type, and writes HTTP/1.1 responses with the correct content length; binary files are copied by length rather than treated as strings. A small in-memory cache stores up to 30 requested files to avoid reading the same assets from disk repeatedly. The server is intentionally synchronous and the frontend in the same repository is plain HTML, CSS, and JavaScript.