简体   繁体   English

如何解决 Heroku 部署中的“方法不允许”

[英]How can I solve "Method not Allowed" in Heroku deploy

I recently tried to deploy my telegram bot on Heroku and I use Flask framework for write webhook code.我最近尝试在Heroku上部署我的电报机器人,并使用Flask框架编写 webhook 代码。 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.使用“git push heroku master”部署我的代码开始出现任何问题,但最后我遇到了这个问题,链接“https://git.heroku.com/serene-crag-92322.git”我得到“方法不允许”消息。 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:来自 Heroku 的消息:

来自 Heroku 的消息:

Heroku creates a git repository with your source code before building and deploying your code. Heroku 在构建和部署代码之前使用您的源代码创建一个 git 存储库。 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).您曾尝试访问外部世界无法访问的私有 Git 存储库(因此出现Method Not Allowed错误消息)。 But the actual website where your web app is deployed is different.但是部署 Web 应用程序的实际网站是不同的。 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.该 Web 应用程序包含您的应用程序名称,如果您在 Heroku 应用程序创建期间提供了一个,否则会为您的 Web 应用程序提供一个随机名称。

Heroku Git Repository Link: https://git.heroku.com/serene-crag-92322.git Heroku Git 存储库链接: https ://git.heroku.com/serene-crag-92322.git

Deployed Heroku App Link: http://serene-crag-92322.herokuapp.com/部署的 Heroku 应用链接: http ://serene-crag-92322.herokuapp.com/

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

相关问题 如何解决 Flask/Heroku 错误:“Method Not Allowed The method is not allowed for the requested URL” - How to solve Flask/Heroku Error: “Method Not Allowed The method is not allowed for the requested URL” 如何解决python登录脚本中的方法POST不允许错误? - How can I solve method POST not allowed error in python Login script? 如何解决 heroku 上的应用程序错误? - How can I solve application error on heroku? 如何解决方法“POST”不允许 405 - How to solve Method “POST” not allowed 405 将 Bot 部署到 Heroku 时如何解决 TypeError? - How can I solve a TypeError when deploying my Bot to Heroku? 我如何解决在heroku上托管的Django项目中的迁移问题? - How can i solve a migration issue in django project hosted on heroku? 我如何使用 static 文件将 Django 部署到 Heroku - How can i deploy Django to Heroku with static files 如何使用 Flask 部署 pywebio 应用程序,(以便我可以在 heroku 等网站上部署) - How to deploy a pywebio application using Flask, (so that I can deploy in websites like heroku etc) 我可以在没有虚拟环境的情况下部署到 Heroku 吗? - Can I deploy to Heroku without a Virtual Environment? 我无法使用Django部署到heroku - I can't deploy to heroku with django
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM