HTML-форма
Код: Выделить всё
CSV file
Код: Выделить всё
from flask import Flask, request, Response, redirect, flash, render_template
from io import BytesIO
import pandas as pd
@app.route('/uploader', methods = ['POST'])
def uploadFile():
uploaded_file = request.files['input_file']
data_df = pd.read_csv(BytesIO(uploaded_file.read()))
# do stuff
# stream the pandas df as a csv to the user download folder
return Response(data_df.to_csv(index = False),
mimetype = "text/csv",
headers = {"Content-Disposition": "attachment; filename=result.csv"})
Однако я хотел бы отобразить страницу «Загрузка завершена» после ее завершения.
Как мне это сделать? Обычно я использую return redirect("some_url") для смены страниц.
Подробнее здесь: https://stackoverflow.com/questions/730 ... aming-data
Мобильная версия