Flask - Using external blueprints

271 Views Asked by At

I am working on a big flask project, which supports flask-plugins. I need to add a feature which allows the user to upload files from his own PC. As I did not want to edit the core code of the server, I thought of adding this functionality by creating a plugin.

There is a blueprint already present in the core code by the name of blueprint as follows -

pybossa/views/projects.py

blueprint = Blueprint('projects', __name__)

And it is registered and has a url_prefix set in core.py -

pybossa/core.py

from pybossa.views.projects.py import blueprint as projects
app.register_blueprint(projects, '/projects')

Now I have a plugin called testUploader, and I am importing the blueprint 'projects' as follows -

pybossa/plugins/testUploader/views.py

from pybossa.view.projects import blueprint

@blueprint.route('/test')
def testUpload():
    return("Hello World")

As you can see, I have created a new blueprint route /test

But when I go to localhost:5000/projects/test, I get 404 page not found.

Why is the route not working?

0

There are 0 best solutions below