简体   繁体   English

将 Python Telegram Bot 部署到 Heroku

[英]Deploy Python Telegram Bot to Heroku

I Tried to deploy my python telegram bot on Heroku but when the Deploy end I Click to View it gives me Application Error.我试图在 Heroku 上部署我的 python 电报机器人,但是当部署结束时,我单击查看它给了我应用程序错误。 My Code is Running locally on PyCharm very well, I Prepare all the Requirements files to Deploy on Heroku(Requirement.txt & Procfile) and Uploaded them to GitHub.我的代码在 PyCharm 上本地运行得很好,我准备好所有需求文件以部署在 Heroku(Requirement.txt 和 Procfile)上并将它们上传到 GitHub。

This is my Code in GitHub: https://github.com/mohammad122333/python-telegram-bot这是我在 GitHub 中的代码: https://github.com/mohammad122333/python-telegram-bot

Another Question Can I Deploy my Code Without GitHub To keep my code Secure?另一个问题 我可以在没有 GitHub 的情况下部署我的代码以确保我的代码安全吗?

I'm new in stack overflow, Programming python and speaking English so Forgive me if there is a mistake..我是堆栈溢出的新手,编程 python 和说英语所以如果有错误请见谅..

You don't have a Procfile, see https://devcenter.heroku.com/articles/procfile您没有 Procfile,请参阅https://devcenter.heroku.com/articles/procfile

It tells Heroku how your project is executed.它告诉 Heroku 你的项目是如何执行的。

Don't commit sensitive information such as tokens to git.不要向 git 提交令牌等敏感信息。 Instead define them as environment variables.而是将它们定义为环境变量。 On the Heroku Dashboard you can use the environment variabl, see https://devcenter.heroku.com/articles/config-vars在 Heroku 仪表板上,您可以使用环境变量,请参阅https://devcenter.heroku.com/articles/config-vars

In Python you would retrieve the value of an environment variable via:在 Python 中,您可以通过以下方式检索环境变量的值:

import os
TOKEN = os.environ["TOKEN"]

You should always supply the entire log.您应该始终提供整个日志。 It tells so much more information than just saying it does not work.它提供了更多信息,而不仅仅是说它不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM