I have problem to write data into file from my flask developments server (win7),
@app.route('/')
def main():
fo = open("test.txt","wb")
fo.write("This is Test Data")
return render_template('index.html')
Why this don't works in flask ?
You should either flush the output to the file or close the file because the data may still be present in the I/O buffer.
Even better use the with statement as it'll automatically close the file for you.
with open("test.txt", "w") as fo:
fo.write("This is Test Data")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With