OpenShift V3 set variable for project

和自甴很熟 提交于 2019-12-11 14:16:37

问题


I created a bot for Discord in python. The bot requires a token for connection to my server and i don't want to store the token in a python file, because everyone would see it on github.

I added an Enviroment variable for my bot token with the same variable name as in the python file (BOT_TOKEN), but the OpenShift doesn't recognizes it.

I got the following error:

---> Running application from Python script (main.py) ...
Traceback (most recent call last):
  File "main.py", line 22, in <module>
    client.run(BOT_TOKEN)
NameError: name 'BOT_TOKEN' is not defined
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f001d95fdd8>

How can i set a variable for my bot token without uploading it to github?

(Sorry for my English)


回答1:


Assuming that you have added the environment variable correctly, shouldn't your code be client.run(os.environ.get('BOT_TOKEN') ?



来源:https://stackoverflow.com/questions/47080174/openshift-v3-set-variable-for-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!