DEV Community

Cover image for Why Flask?
tcs224
tcs224

Posted on

Why Flask?

Flask lets you build web apps with Python. It lets you build both simple and complex web apps (what is Flask).

I like it over Django because you are in full control of the architecture choices. But of course, you should make your own choices. Perhaps you prefer Tornado

Django makes a lot of choices for you, like that you have to use an ORM (Object-relational mapping). In general I prefer having raw SQL queries than using an ORM.

Flask was made several years after Django and therefore learned from the Python community's reactions.

Why Flask

There are many reasons to choose Flask. For one it's a microframework, so you can learn it quite fast. Some other reasons to choice Flask are:

  • Flask is actively maintained and developed

  • It is extensible while maintaining a simple core

  • The documentation is great

  • It's easy to get started with Flask as a beginner. There is a tiny boilerplate code for getting a simple app up and running.

  • It saves you development time (Easy to deploy Flask apps)

flask meme

Flexibility

It has a template engine available (Jinja2) but you are not forced to use it. If you prefer using your own engine, you can with Flask. This flexibility is one of the great things about Flask.

In fact, if you want to return just plain html you can.

@app.route('/')
def root():
    return app.send_static_file('index.html')

It relies on a plug-gable approach, the developer can include the modules he or she needs for the project.

Conclusion

Flask is great (in my opinion), but you should use what makes most sense to you. If you already have a project in another framework, it may not be the best idea to rewrite the whole code.

Related links:

Top comments (2)

Collapse
 
otaviocapila profile image
Otávio Capila

Do you know any platform or website built using Flask?

Collapse
 
tcs224 profile image
tcs224

There are several: Pinterest, Twilio engineering blog, Lemur (Netflix).