Question : dotenv python
Answered by : graceful-gull-fu4euk7brmtg
# Install dotenv via:
pip3 install python-dotenv
# Load .env file using:
from dotenv import load_dotenv
load_dotenv()
# Use the variable with:
import os
os.getenv("ACCESS_KEY")
Source : | Last Update : Sat, 16 May 20
Question : python install dotenv
Answered by : nk
pip install python-dotenv
Source : | Last Update : Sun, 27 Dec 20
Question : get dotenv variable python
Answered by : chifarol
# Install dotenv via:
pip3 install python-dotenv #in views.py
# Load .env file using:
from dotenv import load_dotenv
load_dotenv()
# Use the variable with:
import os
os.getenv("ACCESS_KEY")
Source : | Last Update : Sat, 06 Aug 22
Question : usage of python-dotenv
Answered by : embarrassed-emu-yfh91x3e8rpt
"""
create a file in local directory
touch .env
add entries with following format:
SECRET_KEY=secret_token_here
"""
from dotenv import load_dotenv
import os
# By Default below line will load a file ".env" in current working directory
load_dotenv()
secret_key = os.getenv('SECRET_KEY')
print(secret_key)
Source : https://ioflood.com/blog/python-dotenv-guide-how-to-use-environment-variables-in-python/ | Last Update : Tue, 17 Oct 23