Dec-30-2018, 02:02 PM
Hi
Im new att flask. Im trying to port an desktop app i made to the web so im using flask to do it.
Well what im trying to do is to generate a file with a list of data typed in a form in the html and then make it available for download and later on the file gets removed.
here is my code so far
So my questions are there a better way to do it maybe buffer all the data before generate the file with it for download and after download it gets removed.
Im new att flask. Im trying to port an desktop app i made to the web so im using flask to do it.
Well what im trying to do is to generate a file with a list of data typed in a form in the html and then make it available for download and later on the file gets removed.
here is my code so far
@app.route('/result',methods = ['POST', 'GET']) def result(): if request.method == 'POST': cablename = request.form['cablename'] parts = int(request.form['parts']) result = request.form print('{}.{}'.format(cablename, parts)) for part in range(parts): print('{}.{}'.format(cablename, part+1)) file1.writelines('{}.{}\n'.format(cablename, part+1)) file1.flush() return render_template("result.html",result = result)This code makes a file with a list of the data but i dont know how to make it available for download and im not sure if its the best way to do it.
So my questions are there a better way to do it maybe buffer all the data before generate the file with it for download and after download it gets removed.