项目的OpenShift V3设置变量 [英] OpenShift V3 set variable for project

查看:96
本文介绍了项目的OpenShift V3设置变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在python中为Discord创建了一个机器人.该机器人需要令牌才能连接到我的服务器,并且我不想将令牌存储在python文件中,因为每个人都可以在github上看到它.

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.

我为我的机器人令牌添加了一个环境变量,其变量名与python文件(BOT_TOKEN)中的变量名相同,但OpenShift不能识别它.

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.

我遇到以下错误:

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

如何在不将其上载到github的情况下为我的机器人令牌设置变量?

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

(对不起,我的英语)

推荐答案

假设您已经正确添加了环境变量,那么您的代码应该不是client.run(os.environ.get('BOT_TOKEN')吗?

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

这篇关于项目的OpenShift V3设置变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆