Hello Traveler.

This page assembles some information around my Flask-Todolist project.

The idea was to explore the Flask ecosystem and try to build a small web application. Small as it should not be fancy in any way, but atleast tackle the most common patterns/features of a web application.

So you'll find an API, User-Management (Register/Login) and the accoring views + to do lists (obviously). If your interested, check it out! In 4 Steps you can get up and running:

pip install -r requirements.txt
export FLASK_APP=./todolist.py
flask fill_db
flask run

This uses Flask 0.11 which added the flask command, which I really like.

Now you can explore the app on http://localhost:5000/

Reasons for this project

As mentioned before, the reason for the existence of this project is for me to explore Flask and its many extensions.

At this point I'm fairly new to web development and wanted to get started in an uncomplicated fashion, thus Flask seemed reasonable. Also this project might be a quick start for other developers looking into Flask.

Encouragement

Flask is cool! Let me show it.

@api.route('/todolists/')
def get_todolists():
    todolists = TodoList.query.all()
    return jsonify({
        'todolists': [todolist.to_json() for todolist in todolists]
    })

Just 6 lines for an API view, which will display all todolists as JSON.

The decorator does multiple things. It registers a route on the api blueprint. Which are the Flask way of modularization. As I see it, equivalent to apps in Django. Here the api blueprint is prefixed with 'api', i.e. http://localhost:5000/api/todolists/ would be the link for the above view.

TodoList is a class based upon SQLAlchemy which is seemingly the way to go in terms of an ORM for Flask (specifically Flask-SQLAlchemy). And jsonify is a funciton comming from Flask which will return a proper JSON response of a dictionary. Which here is a neat list comprehension of json representations of todolists.

Discouragement

Flask is a micro web development framework for Python.

Well sounds pretty good, right? So it did to me, and still does. The problem or atleast my problem is not with Flask per se, but with the extensions.

In this project I used a few and most of the time it is a breeze, but sometimes you'll find some weird behaviour or don't really get how it works or worse why it doesn't. Although often documentation can be found, it mostly covers quick starts and easy examples, but falls short on going deeper.

So if you, like me, are new to web development this can be discouraging.

Note: after doing the same application using Django, see here I feel somewhat differently. The experience was better with regards to documentation, but I had to read much more documentation just to get up to speed, or so it felt.

Meta

To my fellow travelers I want to say that I found it really usefull to enter such a project. Small enough to do on the side and large enough to actually learn something.

So I'd like to encourage you to try something like this yourself. Not necessarily a Flask project or even a web related one, just something that make you curious.

Here some tips for you adventurers: