def form():
    return """
        <html>
            <body>
                <h1>Transform a file demo</h1>
                <form action="/transform" method="post" enctype="multipart/form-data">
                    <input type="file" name="data_file" />
                    <input type="submit" />
                </form>
            </body>
        </html>
    """

@app.route('/transform', methods=['POST'])
def transform_view():
    file = request.files['data_file']
if not file:
    return 'No file'
file_contents = file.stream.read().decode('utf-8')
result = transform(file_contents)
response = make_response(result)
response.headers['Content-Disposition'] = 'attachment; filename=result.csv'
return response
Uploading and Downloading Files with Flask