Error 405 Method not allowed

It gives me error 405 “Method not allowed”. Only method ‘Get’ works. Here is my cod:
I deliberately made mistakes here:

@app.route('/books/<int: #book_id>/

Because new members can only have two links in their topic.

from flask import Flask, request, render_template, jsonify

app = Flask(name)
app.config[“JSON_AS_ASCII”] = False

@app.route(‘/books/’, methods=[‘GET’])
def read_books():
return jsonify({“content”: “Получаем все книжки”})

@app.route(‘/books/<int: #book_id>/’, methods=[‘GET’])
def read_book(book_id):
return jsonify({“content”: f"Получаем книжку {book_id}"})

@app.route(‘/books/’, methods=[‘POST’])
def create_book():
return jsonify({“content”: “Создаем книжку”})

@app.route(‘/books/<int #:book_id>/’, methods=[‘PUT’])
def update_book(book_id):
return jsonify({“content”: f"Обновляем книжку {book_id}"})

@app.route(‘/books/<int #:book_id>/’, methods=[‘DELETE’])
def delete_book(book_id):
return jsonify({“content”: f"Удаляем книжку {book_id}"})

if name == ‘main’:
from waitress import serve
serve(app, host=‘’, port=5050)

I’m no expert at Python, but I believe these functions should be combined like this:

@app.route("/books/<int: #book_id>", methods=["GET", "POST", "PUT", "DELETE"])
def read_books(book_id):
	if request.method == "GET":
		# I dunno about how this part would work, this is just a guess
		if book_id:
			return jsonify({"content": "Получаем все книжки"})
			return jsonify({"content": f"Получаем книжку {book_id}"})
	elif request.method == "POST":
		return jsonify({"content": "Создаем книжку"})
	elif request.method == "PUT":
		return jsonify({"content": f"Обновляем книжку {book_id}"})
	elif request.method == "DELETE":
		return jsonify({"content": f"Удаляем книжку {book_id}"})

Have a read here: Quickstart — Flask Documentation (2.2.x)