So, here’s why you should learn flask ?

It’s small

Flask is a micro framework. Micro meaning Flask aims to keep the core simple but extensible, there is not much required to get up and running with flask. A simple hello world application in flask takes about 7 lines of code, the steps are as follows:

Install python Install pip ( which is a package manager for python packages ). Install flask Implement the following code example in flask.

from flask import Flask app = Flask() @app.route('/')

def home():

return 'Hello world' if __name__ == '__main__':

app.run()

Here’s what we did in the code example:

First we imported the Flask class. An instance of this class will be our WSGI application. Next we create an instance of this class. The first argument is the name of the application’s module or package. If you are using a single module (as in this example), you should use __name__ because depending on if it’s started as application or imported as module the name will be different (‘__main__’ versus the actual import name). This is needed so that Flask knows where to look for templates, static files, and so on. For more information have a look at the Flask documentation. We then use the route() decorator to tell Flask what URL should trigger our function. The function is given a name which is also used to generate URLs for that particular function, and returns the message we want to display in the user’s browser.

To execute the code above I would recommend that you follow the tutorial below.

Extending the flask application makes it more complex however it still remains small in the sense that only the extensions or packages you want to implement are included, flask does not impose extensions or packages on you that you have to use.

Extensible and flexible

Extensible ? Yes so flask has what are called extensions they are python modules that add functionality and support to our flask application. Flask implements bare-minimum core functionality and lets you decide how you would like to extend it. The extensions are reviewed by the flask core team to ensure that they do not break your application. Also these extensions all well documented so incorporating them into your flask application is seamless.

Let’s take user management as an example, to implement user management in flask you could code it from scratch ( which I strongly advise against for any beginners ) or you can use the extension flask_login which handles tasks such as user logging in, logging out or tracking a users sessions. Just with that one extension you have made flask and the application your building more powerful.

See the flask extensions registry for more extensions available to you when using flask and this registry is updated on a regular basis.

On the other hand Django which is most often compared to flask comes with batteries meaning that it comes with built in packages such as ORM (Object Relational Model) so when you want to customize behavior or follow a non traditional pattern you can, but you have to undo a lot of the work Django’s already done whilst flask gives you the flexibility to decide which extensions to be included.

Easy to learn

Easy like 1–2–3. The learning curve of flask is not as steep because of how simple the API is thus making it easier to learn. The Flask API is void of any complex setup making it easy for beginners to learn and start feeling confident with how to use the API.

You can easily incorporate any extensions because of how they were build and designed according to a common specification or if you choose to write code to extend the functionality of your application which can be time consuming, it however does have the added benefit of help you better understanding python.

As the size of your flask application grows with more complex structures (e.g blueprints), extensions and custom code (e.g view decorators) so does you understanding of flask making it more manageable. These advances topics stay out of the way until you need them and you are not required to learn them on the get go.

The beauty of flask is that it does not force you to use packages or extensions in your application, it’s all up to you based on your needs and skills level.

Community and Learning resources

The community around the framework matters a lot because you will need support when you get stuck or face challenges using flask. Also the community enables the project to keep running and evolving with user needs. Flask has a growing community of user as indicated below.

Stack overflow — on stack overflow flask has over 25k questions meaning there is a community of people answering questions and sharing knowledge about flask so you don’t have to struggle. I do however have mention it’s nothing compared to over 188k questions for django but still the flask community is growing.

GitHub — flask has 41,491 star on GitHub which can be considered a measure of how popular an open source project is. Django on the other hand only has 39,083 stars. The interest around flask is definitely great and serves as a reason to be optimistic that flask will only get better — less bugs and the community will is actively growing — more knowledge and support.

Again the community around flask is not as mature compared to bigger web development frameworks but it’s growing and the learning resources are readily available.

Below are some my highly recommended flask learning resources for anyone getting into flask which I personally use and will help you get started with flask.

Flask Documentation — The most obvious first place to start would be the flask documentation. The docs are very extensive and there is a tutorial on the documentation website that you can follow and it should get you familiar with the basics of flask.

Miguel Grinberg tutorial (blog tutorial) — A very comprehension project based tutorial taking you through how to develop a blog application with flask. Most of this code is re-usable in your own application and can be found on the authors github repo.

Python and Flask Bootcamp (Udemy Course) : This course includes a fully complete Social Network project that includes, User Logins, Followers, Authentication, Blueprints, Templates, SQL Databases, and more!

Flask Web Development, 2nd Edition (Book) — This books was published by Miguel Grinberg and I would highly recommend it.

for more tutorial and resources check here.

Conclusion

In my opinion, flask is probably the best web framework out there and you should consider learning and using it in 2019.

Flask is perfect for beginners that want to get started as quick as possible and also for a more experienced developer who craves freedom and flexibility.

Before you leave and dive head first into flask you might wanna check out these projects built in flask:

Issa-challenge.fun

RockYou.fm

Poweredby — This is a list of websites and projects that disclosed that they are running on Flask.

Enjoy and have fun learning!