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

发布于 2025-02-11 00:54:26 字数 792 浏览 2 评论 0原文

最近,我试图在 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的消息:

“来自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:

The message from Heroku:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骄兵必败 2025-02-18 00:54:26

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文