Skip to content

Instantly share code, notes, and snippets.

@zaccone
Created December 10, 2013 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaccone/021203cab26c9e4b0baf to your computer and use it in GitHub Desktop.
Save zaccone/021203cab26c9e4b0baf to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# Our tutorial's WSGI server
from wsgiref.simple_server import make_server
def application(environ, start_response):
# Sorting and stringifying the environment key, value pairs
response_body = ['%s: %s' % (key, value)
for key, value in sorted(environ.items())]
response_body = '\n'.join(response_body)
status = '200 OK'
response_headers = [('Content-Type', 'text/plain'),
('Content-Length', str(len(response_body)))]
start_response(status, response_headers)
return [response_body]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment