A learning implementation of an HTTP/1.1 server built directly on Python sockets.
The server parses request lines and headers, validates the Host header and requested path, serves local resources, accepts JSON uploads, supports keep-alive connections, and bounds concurrency with a thread pool.
flowchart LR
CLIENT["TCP client"] --> SOCKET["Listening socket"]
SOCKET --> POOL["ThreadPoolExecutor"]
POOL --> PARSE["HTTP parser"]
PARSE --> VALIDATE["Host + path validation"]
VALIDATE --> GET["Static GET"]
VALIDATE --> POST["JSON POST"]
GET --> RESPONSE["HTTP response"]
POST --> DISK[("resources/uploads")]
DISK --> RESPONSE
git clone https://github.com/ReaperXD67/NetworkingProject.git
cd NetworkingProject/Server\ Implemntation
python ../Server.pyThen open http://127.0.0.1:8080. Server.py serves a directory named resources, so run it from Server Implemntation unless you move that folder beside the script.
Example JSON upload:
curl -X POST http://127.0.0.1:8080 \
-H "Host: 127.0.0.1:8080" \
-H "Content-Type: application/json" \
-d '{"message":"hello from the socket client"}'GETfor HTML and selected binary resources.POSTwithapplication/json, persisted underresources/uploads.400,403,404,405,415, and500responses.- HTTP/1.1 keep-alive with a request cap and socket timeout.
- Path traversal checks and a localhost-only
Hostallowlist. - Timestamped per-thread logs.
This is not a replacement for a hardened server such as Caddy, Nginx, or a production ASGI server. It does not implement TLS, chunked transfer encoding, streaming request bodies, complete MIME handling, or a standards-complete parser.