Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Simple wrapper around gevent's wsgi server.Adds simple regex routing, error handling, and json/jsonp handling.

Project Description

gserver 0.2.0

Simple wrapper around gevent that provides a basic routing engine and JSON/JSONP handling.

Here’s a simple usage example:

from gevent.monkey import patch_all; patch_all()
from gevent import queue

from gserver.routes import Routes
from gserver.request import parse_vals
from gserver.wsgi import WSGIServer

routes = Routes()
route = routes.route
route_json = routes.route_json

@route("^/example/$")
def example(req):
    return "hello"

@route("^/poll/$")
def poll(request):
    yield ' ' * 1000
    yield "hello"
    sleep(5)
    yield "goodbye" # connection is closed at this point

@route("^/queue/$")
def q(request):
    def process(b):
        b.put("<div>1</div>")
        sleep(1)
        b.put("<div>2</div>")
        sleep(1)
        b.put("<div>3</div>")

    body = queue.Queue()
    body.put(' ' * 1000)
    body.put("<!doctype html><html><head><title>hola</title><head><body>\n")
    gevent.spawn(process, body)
    return body

@route_json("^/example/(?P<name>\w+)/$", method="GET,POST")
def example_name(request, name=None):
    data = request.query_data
    if request.method == "POST":
        data = request.form_data
    query_age, query_height = parse_vals(data, "age", "height")

    return { "name": name,
             "age": query_age,
             "height": query_height }

if __name__ == "__main__":
    server = WSGIServer(('', 9191), routes, log=None)
    server.serve_forever()

get gserver

Install gevent, and it’s dependencies greenlet and libevent:

sudo easy_install gserver

Download the latest release from Python Package Index or clone the repository

More documentation is on it’s way (check the site for updates)

Provide any feedback and issues on the bug tracker, that should be coming soon.

Release History

Release History

This version
History Node

0.2.0

History Node

0.1.10

History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
gserver-0.2.0.tar.gz (9.0 kB) Copy SHA256 Checksum SHA256 Source Feb 25, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting