Created
October 28, 2014 11:19
-
-
Save fengsp/19e1890fd80e16edc8a4 to your computer and use it in GitHub Desktop.
Streaming data with Python and 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
""" | |
stream | |
~~~~~~ | |
Streaming data with Python and Flask. | |
:copyright: (c) 2014 by Shipeng Feng. | |
:license: BSD. | |
""" | |
import time | |
from flask import Flask, Response | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
def gen(): | |
for c in 'Hello world!': | |
yield c | |
time.sleep(0.5) | |
return Response(gen()) | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment