Saturday 10:50 a.m.–11:20 a.m.

Developing Flask Extensions

Rachel Sanders

Audience level:
Intermediate
Category:
Web Frameworks

Description

You can create a web application with Flask in seven lines of code, and you can grow that app to thousands. How do you create reusable, shareable libraries? We'll use a simple but real extension I created (Flask-FeatureFlags) to look at the different ways you can make Flask awesome.

Abstract

"The idea of Flask is to build a good foundation for all applications. Everything else is up to you or extensions." -- Armin Ronacher, creator of Flask **No batteries included? Make your own.** Flask purposely ships with almost nothing - it's a no-batteries-included toolkit at heart. Most functionality lies in the extension ecosystem, and if you want to share your own code, you'll need to learn how to create one. We'll talk about the architecture of Flask, and go over how you can extend it to add your own functionality. **A working example: Flask-FeatureFlags** When my team moved to continuous integration, we needed a way to deploy but hide incomplete features. I wrote a small library to add feature flagging to our application. Other teams were interested so I rewrote it as a general purpose extension and open sourced it. It's only a hundred lines of code, but it's a good introduction to how you can extend Flask including signal hooks, decorators, and new Jinja functionality. It even works with Python 3. **Where do you go from here?** We'll end with a sampler of Flask extensions that push the envelope to give you an idea of where you can go after the basics.