After researching, I know there is no way to send_file
and render_template
in one return; however, all of the other solutions pointed to a document that is stored on a server. Is there a workaround for a stream to send_file
and load a template either in the same page or another one?
app = Flask(__name__)
@app.route('/', methods=['GET','POST'])
def homes():
if request.method == 'POST':
document = request.files['test']
stream = io.BytesIO(document.read())
doc = aw.Document(stream)
# random doc manipulation
return send_file(doc, as_attachment=True, download_name='test.docx')
return render_template("index.html")