xitiz Posted August 25, 2020 Posted August 25, 2020 I am trying to create a webapp where person can store some data(email and password) but i want to use .txt file while storing their data.Mean i want to store their data into the .txt file but if i try to use with statement in my myapp.py then it gives the internal server error.I am using Flask to create this webapp.
Krydos Posted August 25, 2020 Posted August 25, 2020 Why not store data in a database? If you insist on writing to a file for some reason, I would bet the reason it is failing is permissions.
xitiz Posted August 25, 2020 Author Posted August 25, 2020 (edited) Why not store data in a database? If you insist on writing to a file for some reason, I would bet the reason it is failing is permissions.How is it is to store that much simple data in database then in .txt file?I think storing this simple data in data base is very hard then store that in just .txt file?Don't you think so.And Can i install some needed package like as pickle?To save that data in .txt file. Edited August 25, 2020 by xitiz
Sn1F3rt Posted August 25, 2020 Posted August 25, 2020 "pickle" module comes by default with Python, and FYI it's for binary files. For normal text files, you just use open() function and work on files in read, write and append mode. No module is required for that purpose. Here's a good read - https://www.w3schools.com/python/python_file_open.asp
Krydos Posted August 27, 2020 Posted August 27, 2020 Yes, I would definitely use a database to store emails and passwords for people. Make sure you don't store the passwords in plaintext either. They need to be salted and hashed. Storing emails and passwords in a text file is probably one of the worst ideas I've heard in a long time. What if someone figures out the name of the text file and just goes to yourdomain.heliohost.org/passwords.txt and everything is displayed? It may take a tiny bit more work now to figure out how to use a database and everything, but it will pay off in the long run. Develop good habits today, and you won't end up with a disaster later on.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now