Hi there repl.it users, I just had a question that I needed answering for a game I'm making. I would like to store the amount of points someone gets in one game in a file after someone quits the game. In addition, I would like to make this file unchangeable by any users except me. How can I do this?
The files in your repl can only be modified by you. As for the first part, I recommend using an external DB instead of files, since the data in the files will get reset everytime your repl is run.
@KiKUP ok. If u want it hidden to other users:
1) make a file named
import ast to the beginning of your code
3) Read the file:
with open('.env', 'r') as f: <item name> = ast.literal_eval(f.read())
4)Write data into file:
with open('.env', 'w') as f: f.write(str(<item name>))
here's an example of something I did with this: https://repl.it/@AllAwesome497/LOL-Bot
As stated by TheDrone7 It is highly recommended to use some sort of external database. If you try to use a file on repl while sometimes it will work and save the data it will get corrupt at some point. As for making it unchangeable by any users, handling it server side and protecting it and using some sort of authentification system with tokens might be something you could look into.