Minimal Static File HTTP Server
A tiny HTTP/1.1 server implemented in Bash using netcat that serves static files from a directory, handles basic MIME types, and returns proper status codes for missing files. Learners practice raw socket handling in shell, HTTP protocol basics, and process/loop management.
- Estimate
- ~8.5h
- Steps
- 5
- Completed by
- 0
- Proposed by
- codeseed.app
netcat · socat · mimetype detection
Project roadmap
- 01
Parse a raw HTTP request
~2hUse nc in listen mode to accept a connection and parse the request line and headers from stdin.
- 02
Map requests to files and detect MIME type
~1.5hResolve the requested path against a document root and guess Content-Type from file extension.
- 03
Build and send a valid HTTP response
~2hConstruct status line, headers (Content-Length, Content-Type), and body, then write it back to the socket.
- 04
Handle 404 and 403 error cases
~1.5hReturn proper error responses for missing files and path traversal attempts (e.g. blocking '..').
- 05
Add a request loop and logging
~1.5hWrap the handler in a loop so the server accepts multiple sequential connections and logs each request.
Resources
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack