A lightweight, customizable Python HTTP server with modular request handlers and static file serving.
- Modular request handlers for GET, POST, PUT, PATCH, DELETE
- Serve static files (HTML, JSON, images)
- Easy configuration via
config.py - Utility functions for file and response management
- Simple, extensible codebase for learning or production use
Http_Server/
├── config.py # Server configuration
├── server.py # Main server logic
├── handlers/ # Request handlers (CRUD)
│ ├── get_handler.py
│ ├── post_handler.py
│ ├── put_handler.py
│ ├── patch_handler.py
│ └── delete_handler.py
├── static/ # Static files (HTML, JSON, images)
│ ├── index.html
│ ├── form.html
│ ├── guide.json
│ ├── memories.json
│ └── sample.png
├── utils/ # Utility modules
│ ├── file_utils.py
│ └── response_utils.py
└── requirements.txt # Python dependencies
- Clone the repo
git clone https://github.com/Ada890/PyServerX.git
- Install dependencies
pip install -r requirements.txt
- Run the server
python server.py
- Access the server
- Open your browser and go to
http://localhost:<port>(seeconfig.pyfor port)
- Open your browser and go to
- Add or modify handlers in
handlers/for custom logic - Update
config.pyfor server settings - Place additional static files in
static/
GET /static/index.html HTTP/1.1
Host: localhost:8080Response:
<!DOCTYPE html>
<html>
<head><title>Index</title></head>
<body>Welcome to PyServerX!</body>
</html>POST /api/data HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{
"name": "Dino@rmy",
"message": "Hello, server!"
}Response:
{
"status": "success",
"data": {
"name": "Dino@rmy",
"message": "Hello, server!"
}
}PATCH /api/resource/123 HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{
"message": "Updated message"
}Response:
{
"status": "updated",
"id": 123,
"message": "Updated message"
}PUT /api/resource/123 HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{
"name": "Dino@rmy",
"message": "Replaced message"
}Response:
{
"status": "replaced",
"id": 123,
"data": {
"name": "Dino@rmy",
"message": "Replaced message"
}
}DELETE /api/resource/123 HTTP/1.1
Host: localhost:8080Response:
{
"status": "deleted",
"id": 123
}Built for learning, rapid prototyping, and as a foundation for more advanced Python web servers.