Skip to main content

Yet another Python async server

Project description

Async Server

This project is an asynchronous server built using Python's asyncio.create_server, designed for efficient request handling. It features a simple router-based request dispatcher, static file serving, and logging configuration. The server can handle both GET and POST requests and allows for easy route registration.

Features

  • Async server powered by asyncio.create_server
  • Customizable logging via log levels (debug, info, warning, error)
  • Static file serving (optional)
  • Simple router-based dispatching for request handling, configured in locations.ini
  • Error handling for 404 (Not Found), 405 (Method Not Allowed), and 500 (Internal Server Error)
  • Flexible configuration for host, port, and log levels

How to Run

Default Run

The server starts on 0.0.0.0:8079 by default. You can run the server with the following command:

python -m yapas

Custom Parameters

You can customize the server's host, port, static file path, and logging level with the following command-line options:

python -m yapas --host <host_ip> --port <port_number> --log_level <log_level>

Example

python -m yapas --host 127.0.0.1 --port 8080 --log_level info --use_proxy

Parameters:

  • host: IP address of the server (default: 0.0.0.0)
  • port: Port to bind the server to (default: 8079)
  • log_level: Logging level (debug, info, warning, error) (default: debug)
  • use_proxy: use or not pre-set reverse proxy (see locations.ini), ensure localhost:8000 is listened, if this parameter is set

Error Handling

The server supports custom error handling for common HTTP errors:

  • 404 Not Found: Raised if a route is not found.
  • 405 Method Not Allowed: Raised if the requested method is not supported by the route.
  • 500 Internal Server Error: Raised for any unhandled exceptions.

Static Content Management

  • Basic in-memory caching is implemented for static content.

Signal Handling

  • Server listens signals to gracefully terminate (SIGTERM) or restart (SIGHUP).

Proxy support

  • Server supports a basic reverse proxy feature to forward requests to another backend server, retaining client headers such as User-Agent and Cookies.

Backlog

  • SSL/TLS Support: Add HTTPS support using Python's built-in ssl module to enable secure communication over SSL/TLS.
  • Round Robin Load Balancing: Extend reverse proxying to support multiple backend servers with a round-robin load balancing algorithm for better distribution of incoming requests.

License

This project is licensed under the 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

yapas-0.1.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

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

yapas-0.1.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file yapas-0.1.0.tar.gz.

File metadata

  • Download URL: yapas-0.1.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for yapas-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0fd85d52b98588d4c98eea1a1db64951a9bc4bd6cfc7368839374b418ed22c52
MD5 003e658138a4cf6808fe0b5e6d5e948a
BLAKE2b-256 c811ff74b2f8363e73a2f344ae9208f7e38c48bfac92e6d24ba142067d60e606

See more details on using hashes here.

File details

Details for the file yapas-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: yapas-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for yapas-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebe6592f962feba9583d11c2e33923e3fbf956d8424625ff446141a0f93469b8
MD5 56a2f1c7b74e5f886f683b61f7c2ad21
BLAKE2b-256 1111dd3188c4b8ff74f70991d9b366ac606deff9c0a92a7b7d600af477367811

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