Reputation: 21
As I am trying to create the DB for this online tutorial I am getting the error below when I run the following command in python environment
from api import db,create_app
db.create_all(app=create_app())
The error I am getting is as follows:
File "C:\JS_Class\tests\ng-blog\api\__init__.py", line 21, in create_app
app.register_blueprint(blogs)
AssertionError: View function mapping is overwriting an existing endpoint function: blogs.wrapper
Can Someone push me into the right direction for this as I am stuck and I don't know where to look for more answers...
https://github.com/VladDumitru87/ng-blog
Upvotes: 1
Views: 135
Reputation: 15462
Problem seems to be with the routes inside api/Blog/blog_routes.py
that are decorated with @jwt_required
. For example:
@blogs.route("/delete_blog/<int:id>", methods=["DELETE"])
@jwt_required
def delete_blog(id):
blog = Blog.query.filter_by(id=id).first()
db.session.delete(blog)
db.session.commit()
return jsonify("Blog was deleted"), 200
From looking at the documentation and trying your code out it seems that it should be @jwt_required()
instead of @jwt_required
. So it should look more like this:
@blogs.route("/delete_blog/<int:id>", methods=["DELETE"])
@jwt_required()
def delete_blog(id):
blog = Blog.query.filter_by(id=id).first()
db.session.delete(blog)
db.session.commit()
return jsonify("Blog was deleted"), 200
Change this for all instances where you use @jwt_required
in that file.
Upvotes: 1