Reputation: 955
I am unable to understand the what purpose does blueprints and namespaces serve in web app.
I read the documentation but cannot figure it out exactly.
It would be really helpful for me if you give a simple explanation with example for each case.
Thanks!
Upvotes: 23
Views: 14128
Reputation: 2044
I may still be missing something, but this tutorial seems to clarify the documentation a bit more.
Regarding @code_dredd's comment:
why should anyone choose to use a Blueprint over a Namespace (or viceversa) when both claim to have the same purpose?
Namespaces appear to be intended for organizing REST endpoints within a given API, whereas Blueprints, in this context, appear to be intended for allowing multiple APIs to be mixed and matched with other APIs or non-REST routes on a Flask App
, according to Flask's design specification.
Upvotes: 13
Reputation: 302
As per flask-restplus:
Flask-RESTPlus provides a way to use almost the same pattern as Flask’s blueprint. The main idea is to split your app into reusable namespaces.
from: http://flask-restplus.readthedocs.io/en/stable/scaling.html
namespace is from the Flask-RESTPlus and Blueprint is from flask to organize your app.
the namespaces modules (specific to Flask-RESTPlus) are reusable namespaces designed like you would do with Flask’s Blueprint.
Upvotes: 0