Flask

All things Flask ranging from core framework to all conceivable libraries. Tips on how to utilize Flask’s flexibility to create expressive applications.
Flask
27 May 2019

Managing Flask Session Variables

Using Flask-Session and Flask-Redis to store user session variables.
Managing Flask Session Variables

When building we build applications that handle users, a lot of functionality depends on storing session variables for users. Consider a typical checkout cart: it's quite often that an abandoned cart on any e-commerce website will retain its contents long after a user abandons. Carts sometimes even have their contents persist across devices! To build such functionality, we cannot rely on Flask's default method of storing session variables, which happens via locally stored browser cookies. Instead, we can use a cloud key/value store such as Redis, and leverage a plugin called Flask-Session.

Flask-Session is a Flask plugin which enables

Continue Reading
Flask
04 Apr 2019

Using Flask-Login to Handle User Accounts

Add user authentication to your Flask app with Flask-Login
Using Flask-Login to Handle User Accounts

We’ve covered a lot of Flask goodness in this series thus far. We fully understand how to structure a sensible application; we can serve up complex page templates, and have dived into interacting with databases using Flask-SQLAlchemy. For our next challenge, we’re going to need all of the knowledge we've acquired thus far and much, much more. Welcome to the Super Bowl of Flask development. This. Is. Flask-Login.

Flask-Login is a dope library which handles all aspects of user management, including vital nuances you might not expect. Some noteworthy features include securing parts of our app behind login

Continue Reading
Flask
06 Feb 2019

Manage Database Models with Flask-SQLAlchemy

Connect your Flask app to a database using Flask-SQLAlchemy.
Manage Database Models with Flask-SQLAlchemy

By now you're surely familiar with the benefits of Python's SQLAlchemy library: the all-in-one solution for basically anything database related. Like most major Python libraries, SQLAlchemy has been ported into a version specifically compatible with Flask, aptly named Flask-SQLAlchemy.

Similar to the core SQLAlchemy package, Flask-SQLAlchemy provides an ORM for us to modify application data by easily creating defined models. Regardless of what your database of choice might be, Flask-SQLAlchemy will ensure that the models we create in Python will translate to the syntax of our chosen database. Given the ease-of-use and one-size-fits-all  nature of Flask-SQLAlchemy, it's no wonder that

Continue Reading
Tableau
17 Jan 2019

The Hostile Extraction of Tableau Server Data

Say no to proprietary software constraints. Say no to vendor lock. Say yes to freedom.
The Hostile Extraction of Tableau Server Data

I try my best not to hate on Tableau. It was the software’s combination of power and ease-of-use that drove me to purchase a license in the first place. Ever since then, I’m finding new and exciting ways Tableau intentionally locks users out of their data.

I gave the Tableau Server Client Python library a spin recently in hopes of finding something useful. I decided to (sigh, once more) allow Tableau the benefit of the doubt: after pushing four updates in a single month, maybe things had changed. On the contrary, the Tableau business strategy stands strong: to

Continue Reading
Plotly
20 Dec 2018

Integrate Plotly Dash Into Your Flask App

Crack full control over Plotly Dash by hacking an integration with Flask.
Integrate Plotly Dash Into Your Flask App

Ahh, Plotly. Typing that name into a post headline triggers an emotional cocktail of both pride and embarrassment. Plotly has been at the core of some of the most influential products I’ve personally worked on over the years: a jumble of Fintech and humanitarian clients, all of which are still proudly waving their charts and dashboards around the world. Yet, my mind is boggled by a simple question: what the hell took us so long to write our first post about Plotly? We've been operating Hackers and Slackers for over a full year now... did I seriously write a

Continue Reading
Flask
19 Dec 2018

Demystifying Flask’s Application Factory

Breaking down the nuances of creating a Flask application correctly.
Demystifying Flask’s Application Factory

A 'skill' that's always fascinated me is just how long some engineers can make it in their career while carrying glaringly obvious gaps in their knowledge of the systems they use every day. To my surprise, I've turned corners where I have been that engineer all along, and there's perhaps no better example of this then the time I've spent with Flask.

WARNING: highly opinionated statement incoming: Flask is everything a framework should be. /opinion. That is to say, it isn't really a fully-fledged framework at all. Sure, the term microframework might seem like a cute branding term, but that

Continue Reading
Flask
30 Sep 2018

Configuring Your Flask App

Tips on how to neatly and securely configure your Python Flask application.
Configuring Your Flask App

Becoming minimally familiar with Flask is often an exhilarating experience. To Discover Flask is to rediscover instant gratification itself: all it takes is a mere few seconds for anybody deploy a Python application, alive and well on a development server. I believe the cliche that the hardest part of anything is getting started, so it's no surprise that Flaks can get the imagination brewing.

Indeed, there's no monolithic settings.py files in Flask (thank god). In fact, if you're to take Flask's documentation seriously, they might have you think that configuring Flask can happen any where in your code, any

Continue Reading
Flask
19 Sep 2018

The Art of Routing in Flask

With great flexibility comes great responsibility. Build smarter Flask routes using this in-depth guide.
The Art of Routing in Flask

It isn't often you find somebody sad or miserable enough to detail the inglorious features of web frameworks, such as routing. This is understandable: flexible route creation is an expected part of any framework, and isn't exactly the first thing that comes to mind when thinking about sexy new tools.

My personal frustrations flared with the official release of Flask v1.0. Version 1 of Flask resulted in many fundamental changes to the framework functions, which is usually fine with the proper documentation. As it turns out, coming off the heels of a breaking release is a bad time to

Continue Reading
Flask
17 Sep 2018

Organizing Flask Apps with Blueprints

Introduce structure to your Flask app by utilizing Flask's Blueprints.
Organizing Flask Apps with Blueprints

Flask tutorials have an occasionally nasty habit of oversimplifying what actual Flask apps should look like. Many newcomers to Flask are likely under the misconception that having a single, giant app.py file is a totally normal and acceptable way to build an app. And why shouldn’t they? Almost every tutorial is structured this way, which is fine for simplicity’s sake, but it seems as though an asterisk is missing, which should read: *This is not a good way to build applications.

Good software is organized by separation of concerns. It doesn’t make much sense to keep

Continue Reading
Atlassian
31 Aug 2018

Recreate JIRA Service Desk in Python & Flask

When SaaS doesn't cut it, beat it down and take everything its got.
Recreate JIRA Service Desk in Python & Flask

When it comes to SaaS products in the realm of Service desks, JIRA Service Desk is at the very least, just as powerful as the next solution (Zendesk comes to mind). This naturally begs the question: Why is JIRA Service Desk's pricing model roughly 1/10th of that of it's competitor?

The answer lies within ease of use, but more importantly, presentation. While Atlassian's cloud offering is slowly playing catchup, Atlassian as a company has never quite seemed to nail down the importance of a friendly user interface, nor the importance of this when it comes to worldwide adoption. To

Continue Reading
Flask
15 Aug 2018

The End-to-End Guide to Handling Forms in Flask

Learn to create form logic and templates in Flask with the Flask-WTForms library.
The End-to-End Guide to Handling Forms in Flask

Happy Tuesday everybody! To start this week hot, let's talk about something that everybody hates: forms. The only thing more painful than filling out a form is creating one, much less a functional one with feedback. Listen, if you're into creating pleasant form UI experiences, you're probably into some freaky shit. Call me.

Flask's youth is an advantage in one regard, in that there are only so many libraries available to handle any given task. In this case, there's only one: the aptly named WTForms.

If you don't have a pressing need to create forms in Flask, I won't be

Continue Reading
Flask
31 Jul 2018

Using MongoDB Atlas as your Flask Database

Since you prefer using Python and Flask, I’ll assume we both prefer enjoyable dev.
Using MongoDB Atlas as your Flask Database

It's been roughly a year since MongoDB launched their Stitch: a "back-end as a service" cloud offering. I've been tinkering with Mongo on the cloud ever since... Alright fine, "tinkering with" may better be described as  "accidentally became dependent on it after developing new features in production environments," but I can't really complain thus-far. If you're not familiar, MongoDB Atlas is MongoDB's cloud-hosted database offering; that is to say, the same as any other MongoDB database, except very expensive.

The jury is still out on how MongoDB Atlas and its counterpart Stitch will fit into the picture of next generation

Continue Reading
Flask
23 Jul 2018

Serving Frontend Assets in Flask

When Python developers manage presentation layers.
Serving Frontend Assets in Flask

If you're familiar with Django (or Python to any extent), you've probably accepted the concept of what Python guys refer to as "static assets." Let's take a moment to consider this: at some point in Django's conception a design decision was made: all JavaScript, CSS, or any assets pertaining to the presentation layer belong tucked away into an isolated corner of the framework. Alas, it was decreed: henceforward, only two types of code exist in the universe: Python, and not-Python. Anything that isn't Python is simply a "static" asset to be dealt with either locally or via a CDN somewhere.

Continue Reading
Flask
20 Jul 2018

Powerful Page Templates in Flask With Jinja

Work with markup that writes itself using Flask's built-in Jinja library.
Powerful Page Templates in Flask With Jinja

So you want to build a web application in Python, eh? Hasn't anybody told you... Python is SLOW! Python is subject to CONTEXT SWITCHING! Oh, the HORROR!

Chances are most of these people aren't well-versed in Python at all. I enjoy creating web applications in Flask more-so than I do in Node. Even if we were to put aside somehow the thousands of potentially malicious Javascript libraries needed to stand up a simple app, or the decades of legacy knowledge needed to tolerate the JavaScript ecosystem without going insane: the simplicity of Flask paired and its libraries get the job

Continue Reading