Forums

405 Method Not Allowed

telebot webhuc "POST / HTTP/1.1" 405 153 "-" "curl/8.8.0" как исправить ошибку? вот код

import logging
import telebot
import flask
from flask import Flask
import time
API_TOKEN = ''


logger = telebot.logger
telebot.logger.setLevel(logging. DEBUG)
bot = telebot.TeleBot(API_TOKEN)
app = Flask(__name__)

@bot.message_handler(commands=["start"])
def start(message):
    bot.send_message(message.from_user.id, message)

@app.route( '/', methods=['POST'])
def webhook():
    if flask.request.headers.get('content-type') == 'application/json':
        json_string = flask.request.get_data().decode('utf-8')
        update = telebot.types.Update.de_json(json_string)
        bot.process_new_updates([update])
        return '200'
    else:
        flask.abort(403)
if __name__ == '__main__':
    bot.remove_webhook()
    time.sleep(1)
    bot.set_webhook(url="https://**.pythonanywhere.com/")
    app.run(host="0.0.0.0", port=5522)

None of the code in the if __name__ block is executed when your code is run as a web app. See https://help.pythonanywhere.com/pages/Flask/