Modularizing your flask app


For complex and larger flask project, you probably want to structure you application well.

for example,

ROOT-

---> app.py

---> /tour
--->/tour/controllers.py
--->/tour/__init__.py

---> /user
--->/user/controllers.py
--->/user/__init__.py


For me, i rather put my starter code into app.py instead of __init__.py so clearly my intention are clearly shown.

Sample of my app.py looks like this. This is where i reference my other controllers and hooked up into flask blueprint. Flask blueprint allow us to modularize our app.


Sample of my app.py looks as follow :-

From line 10 and 11, you can see that i am importing my controllers and modularizing it.





My controllers typically looks like this :-


Now you can go and browse http://localhost:port/tour

Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm