Skip to content

Instantly share code, notes, and snippets.

@muety
Last active November 8, 2017 09:01
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 muety/83e22efe6c117ca8194e0aa3976e0a7c to your computer and use it in GitHub Desktop.
Save muety/83e22efe6c117ca8194e0aa3976e0a7c to your computer and use it in GitHub Desktop.
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