Run locally with repl os.environ variables

**I’d like a best approach as to how to run a replit locally that has os.environ variables in secrets? **

I’m running locally on win os and just pasted my strings into the code, hard coded. I’d like to do a better way

Setup so code runs locally. I tried setx and also added through GUI environ variable but that didn’t work, so I hardcoded and web server / flask site runs.

Repl link:

code snippet

Hi @ChrisFigy !
If you are running a repl locally that uses os.environ, you should make a file called .env and put the sensitive info in there.
Hope this helps!

2 Likes

In order for that to work, you’ll need to install python-dotenv, and do this at the top of files you need the env vars in:

import os
from dotenv import load_dotenv
load_dotenv()
2 Likes