Skip to content

Instantly share code, notes, and snippets.

@n1try n1try/wsgi.py
Last active Nov 8, 2017

Embed
What would you like to do?
Sample WSGI web server with Flask
# gunicorn --bind 0.0.0.0:8000 --workers 4 wsgi:app
# gunicorn --bind 0.0.0.0:8000 --workers 1 --threads 12 wsgi:app
import time
from flask import Flask
app = Flask(__name__)
# Requests from one client are not blocked by long-lasting requests from another client, as long as there are workers available
@app.route('/sleep')
def sleep():
time.sleep(10)
return 'I slept for 10 seconds...'
@app.route('/hello')
def hello():
return 'Hello Flask!'
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.