#41: Structure Your Flask App
My little Flask app keeps growing and the more features I add, the more of a mess it gets. Is there some help to structure the application in a more manageable way?
My little Flask app keeps growing and the more features I add, the more of a mess it gets. Is there some help to structure the application in a more manageable way?
Form validation grows rapidly when we add more fields. Therefore, we need a different way to validate our forms than to put the validation logic into the view functions.
As soon as you work with forms you want to validate the user input. Otherwise you collect a lot of garbage in no time.
From small contact forms to whole applications for data collection, forms are an important part of most web applications. Let us look how we can work with forms in Flask.
Decorators are an interesting concept in Python. We use them in Flask to configure routing, but they are not limited to this use case. Let us find out what we can do with them and how they work.
URLs are important for web applications. They are like an API for your application and search engines can use them to rank your site. Flask gives you a lot of flexibility to map URLs to your view functions.
Our web application will be a maintenance nightmare when all our pages contain the full layout of our site. Luckily for us, Jinja offers a simple solution for this problem called template inheritance.
A web application that only returns plain strings is boring. To turn your Flask application into something optical pleasing, we need a template engine like Jinja.
The default launch configuration in VS Code for Flask is a great help. However, there is one little optimisation that massively improves your development experience.
It is now time for me to do some web development. I choose the Flask framework because it allows me to start quickly and later add more functionality when I need it.