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 details)

Uploaded Source

File details

Details for the file wsgigo-1.2.0.tar.gz.

File metadata

  • Download URL: wsgigo-1.2.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for wsgigo-1.2.0.tar.gz
Algorithm Hash digest
SHA256 d9c51009ed9bc1cb091735c181dedabeb53b288fbfd742fa894e396a412f0b15
MD5 b66a10d195923dc26007f27a5809f6e1
BLAKE2b-256 fe0f2a6ddfbb4fba38803c6c18ae625bafccd11636bb80ab8702a4a45279a38f

See more details on using hashes here.

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