Ask coding questions

← Back to all posts
os.environ.get() not working
isaiah08 (86)

I know that you can't see the .env file, but here is what is in it:
I made two .env files: one in the python directory, and one in the root directory. When you go to the /login route on the site, it gives an error that the secret key has not been configured. But in python/, i configured it! Why doesn't it work?

isaiah08 (86)

Flask or has this strange bug: the title of the page shows the error. Hover over the tab and you can see it. @RYANTADIPARTHI

isaiah08 (86)

Or if you want to see it in the shell, you need to scroll up. @RYANTADIPARTHI

Coder100 (18807)

The .env file is only read in the root directory, a bug not a feature.

Oh yeah, also:


the preferred way (r)

isaiah08 (86)

Changed it, still doesn't work. @Coder100

isaiah08 (86)

I fixed it! I just had the secret key configured in

SixBeeps (5320)

The .env file only works in the root directory.

isaiah08 (86)

Ok, i only have it in the root directory. It still doesn't work.