How does one set .env file with the Flask code?
1 Like
- Add to requirements.txt this module python-dotenv · PyPI
- Redo your
pip install -r requirements.txt
if it isn’t done automatically - Put the following in the module loading section of your main file
from dotenv import load_dotenv
load_dotenv()
1 Like
Yes, these have been satisfied already since day 1.
Nevertheless, I’ve re-done everything as suggested, but error still remains
1 Like
You accidentally put the string into your code not the requirements.txt
Those are separate screenshots in one image
the string is in its own
and the requirements is in its own too
Try running each line in glitch’s terminal (in the menu Tools) so type python3
with an enter
Then type each of the lines for a minimal reproducible example
from dotenv import load_dotenv
load_dotenv()
print(len(os.getenv("STATIC_DIR")))
This will print out the length of your static dir variable in .env allowing you to figure out if things are working but not print out your secret itself.
1 Like
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.