Skip to main content

Centipede is a WSGI microframework with a simple decorator based router.

Project description

Centipede is a WSGI microframework with a simple decorator based router. It’s strength is that it models the technology in use and tries not to confuse developers with complex patterns and tricks. It is what I use to stack my rest services these days.

Installation

$ pip install centipede

Defining handlers

from centipede import expose, app

@expose('^/$','GET', content_type='text/plain')
def index(request, response):
    """ Return the index template
    """
    return 'IgglePigglePartyPants.'

import json

@expose('^/twitter$','GET', content_type='application/json')
def twitter(request, response):
    """ Return your twitter status
    """
    return json.dumps({
        'status' : 'My awesome and insightful twitter status. #blah'
    })

application = app()

Templates

I would recommend keeping your html templates static on the client side and use a javascript template library. But if you really need some server side templating, have a look at mako.

Deployment

For deployment it is not a good idea to use the wsgiref simple_server that the run script uses. A much better idea is to run your centipede application behind a WSGI server. There is a bunch. I recommend running uwsgi behind nginx if you are deploying on your own server. Or have a look at heroku.

Heroku

Deploying centipede applications on heroku is dead simple. Just add this to your Procfile.

web: uwsgi -w uwsgi_app -H . --http-socket 0.0.0.0:$PORT

uwsgi

For deployment using uwsgi, we’ve supplied a uwsgi_app.py module and a uwsgi_init script. Modify to fit your needs ;-).

enjoy.

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

centipede-0.1.1dev.tar.gz (2.3 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