- Based on the Flask MVC Template by UWIDCIT
- Python3/pip3
- Packages listed in requirements.txt
$ pip install -r requirements.txt
Configuration information such as the database url/port, credentials, API keys, etc. are to be supplied to the application. However, it is bad practice to stage production information in publicly visible repositories. Instead, all config is provided by a config file or via environment variables.
When running the project in a development environment (such as gitpod) the app is configured via config.py file in the App folder. By default, the config for development uses a sqlite database.
config.py
SQLALCHEMY_DATABASE_URI = "sqlite:///temp-database.db"
SECRET_KEY = "secret key"
JWT_EXPIRATION_DELTA = 7
ENV = "DEVELOPMENT"
When deploying your application to production/staging you must pass in configuration information via environment tab of your render project's dashboard.
N.B. This has been tested on Python 3.9.10. If you are using a different version of Python, you may need to change the version of the python package in requirements.txt.
For development run the serve command (what you execute):
$ flask run
For production using gunicorn (what heroku executes):
$ gunicorn wsgi:app
You can deploy your version of this app to heroku by clicking on the "Deploy to RENDER" link above.
When connecting the project to a fresh empty database ensure the appropriate configuration is set then run the following command.
$ flask init
If changes to the models are made, the database must be 'migrated' so that it can be synced with the new models. Then execute following commands using manage.py. More info here
$ flask db init
$ flask db migrate
$ flask db upgrade
$ flask db --help
Unit and Integration tests are created in the App/test directory.
You can run all application tests with the following command
$ pytest
You can generate a report on your test coverage via the following commands
$ coverage run -m pytest
$ coverage report
You can also generate a detailed html report in a directory named htmlcov with the following command
$ coverage run -m pytest
$ coverage html
If you are adding models you may need to migrate the database with the commands given in the previous database migration section. Alternatively you can delete your database file.