I'm trying to set up the .env file for my project. But it seems incorrect.
I store the .env file in the same folder as the config.py file as below.
|__run.py
|___|myproject
|__config.py
|__.env
Code in my config.py file:
from starlette.config import Config
from starlette.datastructures import Secret, CommaSeparatedStrings
config = Config(".env")
BACKHUG_JWT_AES_KEY = config('BACKHUG_JWT_AES_KEY', default=None)
print(type(BACKHUG_JWT_AES_KEY))
print(BACKHUG_JWT_AES_KEY)
Data in the .env file:
BACKHUG_JWT_AES_KEY="SAMPLE_AES_KEY"
But the result I got was:
<class 'NoneType'>
None
I don't know why it got the None object. How can I fix it?
I run my project from a run.py file.
Code in the run.py file:
import uvicorn
if __name__ == "__main__":
uvicorn.run("myproject.main:app", host="0.0.0.0", port=8888, reload=True)