Home > Enterprise >  How can I solve "Method not Allowed" in Heroku deploy
How can I solve "Method not Allowed" in Heroku deploy

Time:06-26

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:

CodePudding user response:

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/

CodePudding user response:

Telegram bot is an artificial intelligence that implements an IoT or Internet Of Things system that must allow access for users to log in to other applications. Security on Telegram is very tight because users are encrypted. signal serves to capture open source code to github so heroku must have telegram access to be able to login. To solve this problem, you have to run Heroku with an additional script which is usually stored on github.

  1. First login to your Heroku account and Github
  2. Create a new application, enter the name of the application as desired, then click Create Application.
  3. If so, make sure you're signed in with Github and also make sure you have the repository you want to link to Github. 4.Search for Github under Connect to Github, then click it. 5.click Authorize Heroku.
  4. Then enter the name of your Github repository, click search.
  5. If there is, click Connect.
  6. if it is connected, check the Wait for CI to pass before deploy section and click the Enable Automatic Deploy button, continue by clicking Deploy Branch.
  7. Wait for the process, when it is finished click view to make sure it is connected.
  8. If you see errors, the scripts in your repository contain coding errors, meaning you should fix them.
  • Related