Skip to main content

Lightweight HTTP server framework

Project description

PyDobby

Lightweight HTTP server framework built on Python's socket programming using TCP.

Features

  • Routing with path parameters support
  • Query parameter parsing
  • Middleware system for request/response processing
  • Custom headers support

Installation

pip install pydobby

Usage

from pydobby import PyDobby, HTTPRequest, HTTPResponse
import json
import logging

app = PyDobby()

# Custom middleware example
class LoggingMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        logging.info(f"Request: {request.method} {request.path}")
        response = self.get_response(request)
        logging.info(f"Response: {response.status_code}")
        return response

app.register_middleware(LoggingMiddleware)

# Basic route with path parameter
@app.get("/hello/<name>")
def hello(request: HTTPRequest, name: str) -> HTTPResponse:
    return HTTPResponse(body=f"Hello, {name}!")



# JSON handling example
@app.post("/submit")
def submit(request: HTTPRequest) -> HTTPResponse:
    data = json.loads(request.body)
    return HTTPResponse(status_code=201)

# Run the server
if __name__ == "__main__":
    app.start()

Development

  1. Clone the repository:
git clone https://github.com/yourusername/pydobby.git
cd pydobby
  1. Install in development mode:
pip install -e .
  1. Run the example:
python examples/basic_app.py

TODO

Improvements and features:

  • Static File Serving
  • CORS Support
  • Cookie Handling
  • Session Management
  • File Upload
  • SSL Support

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydobby-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydobby-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file pydobby-0.1.1.tar.gz.

File metadata

  • Download URL: pydobby-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.10.16 Linux/5.15.0-127-generic

File hashes

Hashes for pydobby-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8c10be964b95d58cd54571e325e744e2c8945f43128835ea4cba2739455815fe
MD5 2034b83cdab4dc9b97b5dfa3e4d424e9
BLAKE2b-256 03143e4c54e6df3ab0bd5392baba68575d98007aca6b6a21262aa28459553dbb

See more details on using hashes here.

File details

Details for the file pydobby-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pydobby-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.10.16 Linux/5.15.0-127-generic

File hashes

Hashes for pydobby-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 750c85bc6049073feb1b0464b437634f57c44682057eb1db0c81018c142af561
MD5 0f987bdea851a86330266dcc2fbfb077
BLAKE2b-256 715589e5e425ad6e6214871425174128b12eed6cf33021d80f907bbeb68c516e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page