I\'m building my first Flask app and I can\'t figure out a good, clean Pythonic way of organizing my application. I don\'t want to have everything in a single .py file as in
I worked on a social network built on top of Flask. The special thing about my project was that the server is purely serving API endpoints and the frontend is a one-page Backbone app. The Flask structure I took is the following:
├── app
│ ├── api
│ │ ├── auth.py
│ │ └── ...
│ ├── app.py
│ ├── common
│ │ ├── constants.py
│ │ ├── helpers.py
│ │ ├── response.py
│ │ └── ...
│ ├── config.py
│ ├── extensions.py
│ ├── frontend
│ │ └── controllers.py
│ ├── static
│ │ └── ...
│ ├── templates
│ │ ├── app.html
│ │ └── ...
│ └── users
│ ├── UserConstants.py
│ ├── UserForms.py
│ ├── UserHelpers.py
│ ├── UserModels.py
│ └── __init__.py
├── alembic
| ├── version
│ └── ...
├── tests
│ └── ...
You can read the more in-depth post I wrote on the topic here. I found it to be much more intuitive to separate different functional areas to its own folder.
I worked on the code a while ago and open sourced it completely! You can check it out on github.