-
-
Save civic/a67237fc07fdadb97b1a6f5e98c714c8 to your computer and use it in GitHub Desktop.
wsgi-server.py
This file contains 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
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