Flask Restful URLs giving 404 while in a blueprint -


i trying use flask restful blueprint in pattern works other blueprints. keep getting 404 error when go /todos/1

my project setup follows:

folder structure

├── app │   ├── __init__.py │   ├── mod_api │   │   ├── __init__.py │   │   └── routes.py │   ├── main │   │   ├── __init__.py │   │   ├── forms.py │   │   └── views.py │   └── templates │       ├── base.html │       └── home.html ├── config.py ├── manage.py └── requirements.txt 

__init__.py

from flask import flask flask_restful import api flask_bootstrap import bootstrap config import config bootstrap = bootstrap() api = api()  def create_app(config_name):     app = flask(__name__)     app.config.from_object(config[config_name])     config[config_name].init_app(app)      bootstrap.init_app(app)     api.init_app(app)      .main import main main_blueprint     .mod_api import mod_api api_blueprint     app.register_blueprint(main_blueprint)     app.register_blueprint(api_blueprint)     return app 

mod_api/__init__.py

from flask import blueprint  mod_api = blueprint('mod_api', __name__)  . import routes 

api/routes.py

from flask_restful import resource .. import api  class todoitem(resource):     def get(self, id):         return {'task': 'say "hello, world!"'}  api.add_resource(todoitem, '/todos/<int:id>') 

what doing wrong??

i had same problem, solution is:

api.init_app(api_blueprint) 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -