skip to navigation
skip to content

Not Logged In

gserver 0.2.0

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

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

def example(req):
    return "hello"

def poll(request):
    yield ' ' * 1000
    yield "hello"
    yield "goodbye" # connection is closed at this point

def q(request):
    def process(b):

    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)

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.

File Type Py Version Uploaded on Size
gserver-0.2.0.tar.gz (md5) Source 2014-02-25 8KB
  • Downloads (All Versions):
  • 14 downloads in the last day
  • 213 downloads in the last week
  • 755 downloads in the last month