Environment Variable values #3
Answered
by
Qmirdev
mitski-shinm
asked this question in
Q&A
-
Is it possible to update the method of setting values in the app.py file by retrieving them from environment variables instead? |
Beta Was this translation helpful? Give feedback.
Answered by
Qmirdev
Mar 16, 2024
Replies: 1 comment
-
Yes, for some sensitive informations we can get the variable values from environment variables in import os
BOT_TOKEN = os.environ['BOT_TOKEN']
OWNER_UID = [os.environ['OWNER_UID']]
SERVER_NAME = os.environ['SERVER_NAME']
SERVER_ADDRESS = os.environ['SERVER_ADDRESS']
SERVER_PORT = os.environ['SERVER_PORT']
SERVER_STORE = os.environ['SERVER_STORE']
# Rest of the code So instead of hardcoding the values, you load them from environment variables at runtime. This allows you to configure the values externally without changing code |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mitski-shinm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, for some sensitive informations we can get the variable values from environment variables in
app.py
, you can use the os module in Python:So instead of hardcoding the values, you load them from environment variables at runtime. This allows you to configure the values externally without changing code☺️