Skip to content

Instantly share code, notes, and snippets.

@civic
Created March 5, 2021 07:52
Show Gist options
  • Save civic/a67237fc07fdadb97b1a6f5e98c714c8 to your computer and use it in GitHub Desktop.
Save civic/a67237fc07fdadb97b1a6f5e98c714c8 to your computer and use it in GitHub Desktop.
wsgi-server.py
from wsgiref.simple_server import make_server, WSGIServer
from socketserver import ThreadingMixIn
import time
def hello_world_app(environ, start_response):
start_response('200 OK', [])
path_info = environ['PATH_INFO']
print(path_info)
time.sleep(3)
yield f"Hello World{path_info}\n".encode("utf8")
class ThreadedWSGIServer(ThreadingMixIn, WSGIServer):
pass
http = make_server('', 8000, hello_world_app, server_class=ThreadedWSGIServer)
http.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment