Flask blueprints makes development of a web app super simple. Yes, an easy web app using most powerful programming language Python. Don't go to the confusing Django framework. Flask does it efficiently. I'll explain that in a few simple steps.
- You should have a main app directory where you must include blueprints. That's how it's done usually.
- The main python file should appear there almost barely. Inside this we add the Flask instance, main method and blueprint registration.
- So decide what should be the first blueprint. Profile? Make a folder named Profile.
- Open Profile folder and make it a module. How? Create a Python file named init.py.
- Keep the file blank.Some tutorials teach you to fill init.py. Don't do that. It will make the web app slower.
- Add your Profile related functions and classes right inside the created Python file in that folder.
- To that Python file, which you created earlier, import Blueprints from Flask.
- Add these lines. profile_blueprint=Blueprint('profile', name)
- Go to main file which is in the main app folder. Register the blueprint using lines below. app.register_blueprint(profile_blueprint).
- To use blueprint you must import it. So import it as you do in the case of Python modules. How? from profile import profile_blueprint. The first keyword is the module name and the second is blueprint name.
That's all. Start building your dream today. Do it segmented. Scale gradually. All the best.