Two Flask Books by Miguel Grinberg

Posted on with tags: flask / books

This static blog site started on Github one year ago on April 1, 2009. It has been one year, and it is going better than I originally planned. The most frequent visitor of the site is most likely myself, and the site serves as an online notepad for myself.

I recently finished reading two Flask books by Miguel Grinberg. The first one is Flask Web Development - Developing Web Applications with Python, and the second book is The new and Improved Flask Mega Tutorial. Both books are fantastic. They are better than every Django book I have read, and they are definitely among the top programming books.

Flask books

Here are some tips to work with the Flask Web Development source code flasky.

$ git clone
$ git checkout 8e
$ git checkout -b exercise
$ python -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
$ source  # content see below
$ flask db upgrade
$ flask run

The file sets two environment variables.

export FLASK_DEBUG=1
echo "setup FLASK_APP and FLASK_DEBUG"

If you run the commands above, the flask app will prompt errors because the configuration for the email smtp server is not complete. It is easier to setup a local smtp testing server than setup email accounts. Open a new terminal window and type the command below. The command invokes a standard python module smtpd and starts a debugging email server.

$python -m smtpd -n -c DebuggingServer localhost:8025

In the file, add three lines to the DevelopmentConfig section.

class DevelopmentConfig(Config):
    DEBUG = True
        'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite')
    MAIL_SERVER = os.environ.get('MAIL_SERVER', 'localhost')  ### NEW
    MAIL_PORT = int(os.environ.get('MAIL_PORT', '8025'))
    MAIL_USE_TLS = False

You also need to initialize database when running the code base after Chapter 9 and Chapter 12. The commands are shown below.

$ flask shell
>>> Role.insert_roles()
>>> User.add_self_follows()