How to prevent files generated by my program from being removed, if viewing from Cover Page?

So, my program stores some data in a file placed in the file tree, and it gets removed each time I refresh the Cover Page in my browser after running. I have heard this is normal for the Replit Editor, but is there an actual way to prevent that? Perhaps some settings in the .replit file will help?

Modify the "run" field in the .replit file to execute a command that doesn’t delete the data file. If your program is written in Python and the main file is main.py you can set the “run” field to “python3 main.py”.

2 Likes

Replit comes with running the command specified in the “run” field each time you refresh the cover page, which might include commands that clean up or reset the project. I hope this helps!

I see, thanks! I’ll make sure to take a look at the run command

I believe they meant as in the project writes to files, and they’d like to files not to be erased on a cover page refresh. If this is the case, I’d either recommend using a database, or hosting a website.

Also, the run command does nothing in languages like python (interpreted languages), you must change entrypoint for those.

1 Like

make sure that it works, and see if it changes anything.

Well, we’ll wait and see if it works for them i guess. And if that’s the case, then we just let him know?

Yes, I agree. It’s definetely better to store the data on a database or something. Any file hosting service will work out too

If you don’t have much else using your egress, I’d recommend working with ReplDB, though to persist the data, you’ll need a DB proxy.

This worked, and the file was still there after a refresh. Thank you very much!

The egrees aren’t being used too much for me, so databases like Firebase or Mongo will be totally fine for me.

I was just going to suggest ReplDB, which can be egress intensive at times. (In Python: from replit import db)

I know, will make sure to try this. Thanks anyways!

ReplDB wouldn’t work as it resets on every ghost fork

Which is why I mentioned that they would

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.