You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After struggling with this problem in my application, I managed to recreate the smallest application that triggers this error. The smallest application using flask restless I could think about is this one:
It works.
Now I want to use an application factory pattern. I want to handle models in one file, api blueprints in another, and create my application in a function. I refactor the previous application into this:
fromflaskimportFlaskfromflask_sqlalchemyimportSQLAlchemyfromflask_restlessimportAPIManagerdb=SQLAlchemy()
classThing(db.Model):
id=db.Column(db.Integer, primary_key=True)
api=APIManager()
# api.create_api(Thing, methods=['POST']) # this line causes crash# api.create_api(Thing, methods=['GET']) # this line worksapi.create_api(Thing) # this line worksdefcreate_app():
app=Flask(__name__)
db.init_app(app)
# crash happens at this momentapi.init_app(app, flask_sqlalchemy_db=db)
returnappif__name__=='__main__':
app=create_app()
print(app.url_map)
I've been having this same problem on Flask-Restless==0.17.0. I don't know if this is the correct way to solve this, but putting create_api with the app keyword argument inside an application context seemed to work for me:
After struggling with this problem in my application, I managed to recreate the smallest application that triggers this error. The smallest application using flask restless I could think about is this one:
It works.
Now I want to use an application factory pattern. I want to handle models in one file, api blueprints in another, and create my application in a function. I refactor the previous application into this:
I get the following error:
Strangely, this only happens when I want to use the POST method, not when only using GET
The text was updated successfully, but these errors were encountered: