Skip to Content
Mastering Flask Web Development - Second Edition
book

Mastering Flask Web Development - Second Edition

by Daniel Gaspar, Jack Stouffer
October 2018
Intermediate to advanced
332 pages
8h 9m
English
Packt Publishing
Content preview from Mastering Flask Web Development - Second Edition

Modular application

Currently, your folder structure should look like the following (take a look at the code provided for the previous chapter):

./ 
  config.py 
  database.db 
  main.py 
  manage.py 
  env/ 
  migrations/ 
    versions/ 
  templates/ 
    blog/ 

To convert our code into a more modular application, our files will be structured as follows:

./ 
  manage.py  main.py  config.py 
 database.db 
  webapp/ 
    __init__.py
    blog/
      __init__.py 
      controllers.py      forms.py      models.py    main/      __init__.py      controllers.py
    templates/ 
      blog/ 
  migrations/ 
    versions/ 

The first change to make is to create a folder in your application that will hold the module. In this example, it will be called webapp.

Next, for each module in our application, we will create a respective Python module. If the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Flask Web Development, 2nd Edition

Flask Web Development, 2nd Edition

Miguel Grinberg
Flask Web Development

Flask Web Development

Miguel Grinberg

Publisher Resources

ISBN: 9781788995405Supplemental Content