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