Monday, February 20, 2017

python - Writing to a .txt file in Flask

Writing to a file has nothing to do with Flask. You can learn how to read/write to files here.
Keep in mind writing a large amount of data is slow, and will slow down the request.



if request.method == 'POST' and inputed_email:
# open is a built-in function, w is for write-mode (default is read)
with open('workfile', 'w') as f:
f.write(inputed_email)
return render_template(....)

No comments:

Post a Comment