Skip to content

Ada890/PyServerX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 PyServerX

A lightweight, customizable Python HTTP server with modular request handlers and static file serving.

PyServerX

🌟 Features

  • 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

📁 Project Structure

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

🚦 Quick Start

  1. Clone the repo
    git clone https://github.com/Ada890/PyServerX.git
  2. Install dependencies
    pip install -r requirements.txt
  3. Run the server
    python server.py
  4. Access the server
    • Open your browser and go to http://localhost:<port> (see config.py for port)

🛠️ Customization

  • Add or modify handlers in handlers/ for custom logic
  • Update config.py for server settings
  • Place additional static files in static/

📚 Example Endpoints & Usage

GET Example

GET /static/index.html HTTP/1.1
Host: localhost:8080

Response:

<!DOCTYPE html>
<html>
   <head><title>Index</title></head>
   <body>Welcome to PyServerX!</body>
</html>

POST Example

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 Example

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 Example

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 Example

DELETE /api/resource/123 HTTP/1.1
Host: localhost:8080

Response:

{
   "status": "deleted",
   "id": 123
}

💡 Inspiration

Built for learning, rapid prototyping, and as a foundation for more advanced Python web servers.

About

A lightweight, customizable Python HTTP server with modular request handlers and static file serving.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors