Ever wanted to write a mini web server? Maybe you need an offline web GUI, or just wanted to see how a server works at the bare basics? Today I wrote a 400-line web server application that does the bare basics of fulfilling HTTP 1.1 requests. I also included MIME-type functionality, so when you browse a webpage, you correctly download content (i.e. treat an image as an image, not as a text file).
Unlike Apache Server, I don’t include forking / threading for each session nor do I allow the ability to browser only a set directory. Simply put: this code is a proof of concept and only implements a minimal feature set – don’t use it in production code! If you do use it and expand on the base, tell me what you think and what you’ve added – I’ll be happy to hear of what happens to this code.
Source code is hosted locally here – this should only work for OSX and UNIX-like systems. Play around with the header file includes; some are specific to OSX.
I think my favorite http related hack is . It really helps dispell the notion that something special is going on behind the scenes of a webserver.
also, let me edit my comment so things like the above don’t happen.
and license?
Adam – having technical problems? Send me an email if you want!