ReportBro album application for Flask web framework. This is a fully working demo app to showcase ReportBro and how you can integrate it in your Flask application.
The application is a simple web app and allows to manage a list of music albums. ReportBro Designer is included so you can modify a template which is used when you print a pdf of all your albums.
The Demo App is also avaiable for the Django and web2py web frameworks. See Album App for Django and Album App for web2py respectively.
All Instructions in this file are for a Linux/Mac shell but the commands are easy to adapt for Windows. If a command is different for Windows then it will be shown below. Commands which can be done in Windows Explorer (e.g. copy file, create directory) are not explicitly listed for Windows.
Clone the git repository and change into the created directory:
$ git clone https://github.com/jobsta/albumapp-flask.git
$ cd albumapp-flask
This app requires poetry (version 1.2.2 or newer) to be installed and working. See https://python-poetry.org/docs/#installation for installation details.
Install all dependencies:
To activate the virtual environment:
$ poetry shell
- Create a .flaskenv file to setup app, port (5000) and the flask environment (set to development in the example)
by copying the file flaskenv_example:
$ cp flaskenv_example .flaskenv
- Create and prepare the instance directory
$ mkdir instance && mkdir instance/log
- Copy the example configuration config.py into instance/config.py
$ cp config.py instance
- Create a database (creates albumapp.sqlite in the instance directory):
$ poetry run flask db create
- Compile all translation files so the labels can be used in the application
(generates messages.mo next to messages.po):
$ poetry run flask translate compile
Start the Flask webserver:
$ poetry run flask run
Now your application is running and can be accessed here: http://127.0.0.1:5000
- Open the cloned albumapp-flask directory
- Add virtual env to project:
- Select File -> Settings
- Project: albumapp-flask -> Project interpreter
- click Settings-Icon and select "Add Local" option
- Choose "Poetry Environment" and select "Existing Environment"
- Create a new configuration: Edit Configurations...
- Setup configuration:
- click + button and select Python
- Set the name to something useful, e.g. Debug
- Python interpreter: select virtual env (if not already set)
- Script: select flask from virtual env (env/bin/flask)
- Script parameters: run
- Environment variables:
FLASK_ENV=development
sqlite is used as database to store the application data (albums), report templates and report previews used by ReportBro Designer.
To initially create the db with its tables the following steps are necessary:
Create database (creates albumapp.sqlite db in the instance directory):
$ poetry run flask db create
Extract all texts to the .pot (portable object template) file and create translation file for a given language locale:
$ poetry run flask translate init
Update the translation files:
$ poetry run flask translate update
Compile the translation files that the labels can be used in the application (generates messages.mo next to messages.po):
$ poetry run flask translate compile
The PEP 8 (Python Enhancement Proposal) standard is used which is the de-facto code style guide for Python. An easy-to-read version of PEP 8 can be found at https://pep8.org/