A Web application that demonstrates use of Python's Flask framework. The application makes use of libraries such as the Jinja templating library and WTForms. Architectural design patterns and principles including Repository, Dependency Inversion and Single Responsibility have been used to design the application. The application uses Flask Blueprints to maintain a separation of concerns between application functions. Testing includes unit and end-to-end testing using the pytest tool.
Installation via requirements.txt
$ cd 2021CompSci235-03-CovidWebApp
$ py -3 -m venv venv
$ venv\Scripts\activate
$ pip install -r requirements.txt
When using PyCharm, set the virtual environment using 'File'->'Settings' and select 'Project:2021CompSci235-03-CovidWebApp' from the left menu. Select 'Project Interpreter', click on the gearwheel button and select 'Add'. Click the 'Existing environment' radio button to select the virtual environment.
Running the application
From the 2021CompSci235-03-CovidWebApp directory, and within the activated virtual environment (see venv\Scripts\activate above):
$ flask run
The 2021CompSci235-03-CovidWebApp/.env file contains variable settings. They are set with appropriate values.
FLASK_APP
: Entry point of the application (should always bewsgi.py
).FLASK_ENV
: The environment in which to run the application (eitherdevelopment
orproduction
).SECRET_KEY
: Secret key used to encrypt session data.TESTING
: Set to False for running the application. Overridden and set to True automatically when testing the application.WTF_CSRF_SECRET_KEY
: Secret key used by the WTForm library.
After you have configured pytest as the testing tool for PyCharm (File - Settings - Tools - Python Integrated Tools - Testing), you can then run tests from within PyCharm by right clicking the tests folder and selecting "Run pytest in tests".
Alternatively, from a terminal in the root folder of the project, you can also call 'python -m pytest tests' to run all the tests. PyCharm also provides a built-in terminal, which uses the configured virtual environment.