Chapter 5. Advanced Application Structure

Our application has gone from a very simple example to an extendable foundation on which powerful features can easily be built. However, having our application entirely resided in one file needlessly clutters our code. To make the application code clearer and more comprehensible, we will transform the entire code into a Python module and split the code into multiple files.

The project as a module

Currently, your folder structure should look like this:

webapp/
  config.py
  database.db
  main.py
  manage.py
  env/
  migrations/
    versions/
  static/
    css/
    js/
  templates/
    blog/

To convert our code to a module, our files will be converted to this folder structure:

webapp/ manage.py database.db webapp/ __init__.py config.py forms.py ...

Get Mastering Flask now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.