WSGI application router
Project description
WsgiGo
What is it?
WSGI go is a very simple WSGI router with no requirements. It is written for Python 3, though it could be easily backported.
Installation
pip install wsgigo
Usage
You can use it to route WSGI requests to specific apps based on hostname, URL fragment, or (through extending the Route class) other criteria. For example, suppose you have three wsgi apps which you want to serve as one::
from wsgigo import AppRouter
app = AppRouter(default_app=main_website)
app.add_startswith(docs_app, '/docs/')
app.add_hostname(api_app, 'api.local')
app.add_regexp(animal_app, '/(?:monkey|ape)/')
You can also make your own router class, to route apps how you need them to be routed::
class InternetExplorerRouter(Route):
def claim(self, environ):
user_agent = environ['HTTP_USER_AGENT']
if 'Trident/7.0' in user_agent or 'MSIE' in user_agent:
return True
internet_explorer_app = TestWsgiApp("<b>really simple webpage</b>")
real_app = TestWsgiApp("<b>really ADVANCED webpage</b>")
router = AppRouter(default_app=real_app)
router.add_route(InternetExplorerRouter(internet_explorer_app))
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
wsgigo-1.3.0.tar.gz
(2.9 kB
view details)
Built Distribution
File details
Details for the file wsgigo-1.3.0.tar.gz
.
File metadata
- Download URL: wsgigo-1.3.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa468a0683f6492289908da4ae3f0236041d08618cfc3b70d8a001945422ee9b |
|
MD5 | 02ce4b3f7136b5759c3cbf62fe7f148c |
|
BLAKE2b-256 | 090ce85b78d88d9c6e70005c2792d3bf43aebd8613851da85aedb37092a2c808 |
File details
Details for the file wsgigo-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: wsgigo-1.3.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 679404b946a03116222afd2085b9b9fdfe5eddf6f2278cc64938da7dbe91e4be |
|
MD5 | 070489dcc2c8177d5ce5406b29e4b2bd |
|
BLAKE2b-256 | ef038c38301d4b4603a85d9ac42bdcf6f56a919e4f48854633c47819ea53831a |