Example #1
0
def main():

    """
    Main entry point of the WSGI application.s
    """
    LOG = setup_logging('tstenwi')
    host="0.0.0.0"
    port=10009
    LOG.warning("Running HTTP server on %s:%s...", host, port)
    httpd = make_server(host, port, application)
    httpd.serve_forever()
Example #2
0
def application(environ, start_response):
    """Main entry point of the WSGI application."""
    setup_testing_defaults(environ)
    LOG = setup_logging('tstenwi')
    LOG.warning("Processing request: %s" % environ['REQUEST_METHOD'])
    result = [{"name":"John Johnson","street":"Oslo West 555","age":33}]
    response_body = json.dumps(result)

#    response_body = 'The request method was %s' % environ['REQUEST_METHOD']
    status = '200 OK'
    headers = [('application/json', 'text/plain'),('Content Length', str(len(response_body)))]

    start_response(status, headers)

#    ret = ["%s: %s\n" % (key, value)
#        for key, value in environ.iteritems()]
    return [response_body]