我如何解决“不允许的方法”在Heroku部署中
最近,我试图在 Heroku 上部署电报机器人,并使用 Blask 框架来编写Webhook代码。通过使用“ git push heroku master”部署我的代码始于任何问题,但最后我遇到了链接https://git.heroku.com/serene-crag-92322.git。 >“不允许的方法” 消息。请帮助我解决这个问题,并提前感谢您。 我的烧瓶代码:
@app.route('/' + TOKEN, methods=['POST'])
def getMessage():
json_string = request.get_data().decode('utf-8')
update = telebot.types.Update.de_json(json_string)
bot.process_new_updates([update])
return "!", 200
@app.route("/")
def webhook():
bot.remove_webhook()
bot.set_webhook(
url='https://gentle-temple-77151.herokuapp.com/' + TOKEN)
return "!", 200
if __name__ == "__main__":
app.run()
来自Heroku的消息:
I recently tried to deploy my telegram bot on Heroku and I use Flask framework for write webhook code. With using "git push heroku master" deploying my codes began with any problems, But at the end I encountered this problem that the link "https://git.heroku.com/serene-crag-92322.git" I get "Method Not Allowed" message. Please help me to solve this problem and thank you in advance.
My Flask code:
@app.route('/' + TOKEN, methods=['POST'])
def getMessage():
json_string = request.get_data().decode('utf-8')
update = telebot.types.Update.de_json(json_string)
bot.process_new_updates([update])
return "!", 200
@app.route("/")
def webhook():
bot.remove_webhook()
bot.set_webhook(
url='https://gentle-temple-77151.herokuapp.com/' + TOKEN)
return "!", 200
if __name__ == "__main__":
app.run()
The message from Heroku:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Heroku在构建和部署代码之前,使用您的源代码创建一个GIT存储库。您曾尝试访问该私人GIT存储库,这是外界无法访问的(因此,不允许出现
方法
错误消息)。但是,部署Web应用程序的实际网站是不同的。该Web应用程序包含您的应用程序名称,如果您在Heroku应用程序创建过程中给出了一个应用程序名称,则为Web应用程序提供了一个随机名称。heroku git存储库链接: https://git.heroku.com/ 。
com/
Heroku creates a git repository with your source code before building and deploying your code. You had tried to access that private Git repository, which is not accessible to the outside world (therefore, the
Method Not Allowed
error message appeared). But the actual website where your web app is deployed is different. That web app includes your app name, if you had given one during Heroku app creation, else a random name is given to your web app.Heroku Git Repository Link: https://git.heroku.com/serene-crag-92322.git
Deployed Heroku App Link: http://serene-crag-92322.herokuapp.com/