Created
November 5, 2015 09:07
-
-
Save jossef/410ccc359e89949f2530 to your computer and use it in GitHub Desktop.
simple wsgi script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from wsgiref.simple_server import make_server | |
| port = 8080 | |
| def request_handler(environ, start_response): | |
| status = '200 OK' | |
| headers = [('Content-Type', 'application/json')] | |
| start_response(status, headers) | |
| method = environ['REQUEST_METHOD'] | |
| uri = environ['PATH'] | |
| return ["%s: %s\n" % (key, value) for key, value in environ.iteritems()] | |
| if __name__ == "__main__": | |
| httpd = make_server('0.0.0.0', port, request_handler) | |
| print "Serving on port {0}...".format(port) | |
| httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment