Created
November 7, 2017 21:06
-
-
Save superboum/a5b509328d2c22c77559693140445b6e to your computer and use it in GitHub Desktop.
Webserver that generates files of 100MB on the fly
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
# run with FLASK_APP=server.py flask run | |
# download your file on http://127.0.0.1:5000/random | |
from flask import Flask | |
from flask import Response | |
import os | |
app = Flask(__name__) | |
@app.route('/random') | |
def gen_random(): | |
def generate(): | |
for i in range(1024 * 100) : | |
yield os.urandom(1024) | |
return Response(generate(), mimetype='application/octet-stream') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment