Loading the created flask html page

I want to put a button on a flask-created web page and allow the user to load the html page into a file when the user clicks the button. I suppose this is something like saving the displayed html to BytesIO and sending it via send_file , but I cannot find how to save the displayed page to an object file. How can i do this?

+5
source share
1 answer

You can try something like this:

 import StringIO from flask import Flask, send_file, render_template def page_code(): strIO = StringIO.StringIO() strIO.write(render_template('hello.html', name='World')) strIO.seek(0) return send_file(strIO, attachment_filename="testing.txt", as_attachment=True) 

It is not tested, but should give you an idea.

+4
source

Source: https://habr.com/ru/post/1234873/


All Articles