Skip to main content

Simple wsgi app that routes requests to other wsgi apps. A WSGI router.

Project description

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.2.0.tar.gz (3.4 kB view hashes)

Uploaded Source

Supported by

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