abubakar-webmaker/http-server-from-scratch ? reverse-engineered prompt

Reverse engineered prompt

Build me a small but solid HTTP server in Python from scratch using only the standard library.

I want it to behave like a real HTTP 1.1 server, so it should handle common methods like GET, POST, PUT, DELETE, PATCH, and HEAD, parse requests properly, send correct status codes and headers, and support keep alive so one connection can handle multiple requests. It should also route simple paths and dynamic ones like /users/1 or /users/1/posts/9, serve static files safely from a folder, and block directory traversal attempts.

Please add gzip compression for responses when it makes sense, basic rate limiting per IP, and clean error handling for 404, 405, and bad requests. A graceful shutdown would be great too. Keep the code organized and readable, and include tests that cover the parser, router, static file serving, security checks, and a few end to end request cases. If you need to look up current Python docs or HTTP behavior details online, go ahead.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab