Source

wsgiserialize / test.py

Full commit
import wsgiserialize.jsonize
import wsgiserialize.yamlize
import wsgiserialize.pickler
import wsgiserialize.cpickler
import wsgiserialize.xmlrpcer

from wsgiref.simple_server import make_server
from urlrelay import URLRelay

@wsgiserialize.jsonize.jsonize
def json_app(environ, start_response):
    start_response('200 OK', [('Content-type','text/plain')])
    return {'test':'Hello world!'}

@wsgiserialize.yamlize.yamlize
def yaml_app(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ('Hello World!\n')

@wsgiserialize.pickler.pickler
def pick_app(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ('Hello World!\n')

@wsgiserialize.cpickler.cpickler
def cpick_app(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ('Hello World!\n')

@wsgiserialize.xmlrpcer.xmlrpcer
def xmlrpc_app(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ('Hello World!\n')

urls = (('^/json$', json_app), ('^/yaml$', yaml_app), ('^/cpickle$', cpick_app), ('^/pickle$', pick_app), ('^/xmlrpc$', xmlrpc_app))

httpd = make_server('', 8080, URLRelay(urls))
httpd.serve_forever()