Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Internet > HTTP (WWW)

    Centipede 0.2.5

    Download button

    No screenshots available
    Downloads: 157  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Asbjorn Enge | More programs
    BSD License / FREE
    February 24th, 2012, 04:29 GMT [view history]
    ROOT / Internet / HTTP (WWW)

     Read user reviews (0)  Refer to a friend  Subscribe

    Centipede description

    A WSGI microframework with a simple decorator based router

    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 inherits strongly from urlrelay.

    Installation

    pip install centipede

    Defining handlers

    With Centipede you expose functions to urls. Functions either return a string or a tuple. A string is treated as the document body, http status is set to 200 OK and returned to the browser. Should you return a tuple, status code, body and headers are expected. The expose decorator also supports a few arguments.

    from centipede import expose, app

    @expose('^/$')
    def index(request):
     """ Simple Hello IgglePigglePartyPants
     """
     return 'Hello IgglePigglePartyPants!'


    @expose('^/google$')
    def index(request):
     """ A redirect
     """
     return (307, '', {'Location':'http://google.com'})

    import json


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


    application = app()

    Expose arguments

    The expose decorator looks like this:

    expose(url_pattern, method=None, content_type='text/html', charset='UTF-8')

    Request

    The parameter passed to the functions exposed - in the examples above named request - is the WSGI environ dictionary.

    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 a good idea to run your centipede application behind a good WSGI server. There is a bunch. Gunicorn is good. I usually end up running uwsgi behind nginx.


    Product's homepage

    Requirements:

    · Python

    What's New in This Release: [ read full changelog ]

    · Separated query string params and form data
    · Form data in data key
    · Query string params in params key
    · Improved error handling for unpacking params (needs more work)

      


    TAGS:

    WSGI microframework | decorator router | WSGI | microframework | decorator

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM