Monday, 20 February 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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...