Skip to content

Environment Variable values #3

Answered by Qmirdev
mitski-shinm asked this question in Q&A
Discussion options

You must be logged in to vote

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:

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 ☺️

Replies: 1 comment

Comment options

You must be logged in to vote
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
Category
Q&A
Labels
enhancement New feature or request question Further information is requested
2 participants