A personalisable UK COVID-19 Dashboard used for demonstration purposes.
Project description
Covid Dashboard
Automatic covid dashboard for displaying accurate, up to date covid data and news.
Documentation can be found here.
This project is hosted on GitHub
Table of Contents
Features
- Display up-to-date COVID-19 statistics
- Display both local and national articles
- Display recent news articles about the configured search terms
- Remove articles from being displayed, even after new ones are fetched
- Schedule one-time and repeating updates to fetch new statistics and news articles
- All configurable
Installing
Installing the dashboard is simple.
Ensure pip is up to date
python -m pip install –upgrade pip
Using pip
Simply run
pip install covid19-dashboard-pkg-hwhittle
From Source
Install the required pip modules using the following command
python -m pip install -r requirements.txt
Running
Running the dashboard is easy. You have two options;
- Using the main module
- Flask's CLI
Main Module
Assuming you have python and this module installed simply run in a directory with a config.json file in it
python -m covid19dashboard
Flask CLI
First you need to export the necessary variables
CMD
set FLASK_APP="covid19dashboard/__main__.py"
Powershell
$env:FLASK_APP="covid19dashboard/__main__.py"
Bash
export FLASK_APP="covid19dashboard/__main__.py"
Then run the app using
flask run
This will start the interface at 127.0.0.1:5000/index which can simply be navigated to with any web browser.
Documentation
This project uses Sphinx's documentation generator!
The documentation can be accessed here.
Rebuilding Documentation
Firstly, delete the html and doctrees directories in docs/.
Secondly in the docs directory run:
make html
Config File
This project has a configuration JSON file which can be used to customize the dashboard.
The default configuration is as follows:
{
"logging": {
"enabled": true,
"debug": false,
"path": "./logging/log",
"use_file": true,
"dump_debug_on_error": true,
"dump_debug_count": 10
},
"template": {
"title": "COVID-19 UK Dashboard",
"logo": "logo.webp",
"favicon": "favicon.webp"
},
"location": "Exeter",
"location_type": "ltla",
"nation_location": "England",
"search_terms": "Covid COVID-19 coronavirus",
"language_code": "en",
"news_api_key": "news-api-key",
"resource_path": "./resources/",
"static_path": "./static/",
"inital_national_data_filename": "nation_2021-10-28.csv"
}
Logging
enabled : boolean
Whether or not the logging module is enabled.
This disables debug, info and error logs as well as file writes.
debug : boolean
This toggles whether or not to log debug messages to the console.
They will still be written to a file upon error.
path : string
The path to the log file. Can be relative or absolute.
use_file : boolean
Whether to write info and error logs to a file.
dump_debug_on_error : boolean
Whether to log the history of debug messages when an error log occurs.
The number of debug messages to log is configurable.
dump_debug_count : number
The number of debug messages to log.
Template
title : string
The title to display at the top of the template page.
logo : string
The logo image path relative to /static/images/ (where /static/ is the static directory)
favicon : string
The favicon image path relative to /static/images/ (where /static/ is the static directory)
news_article_count : number The number of news articles to show on the screen at any given time.
Core
location : string
The location in which to query covid data for.
The valid values for this config option depends on the value of location_type.
location_type : string
The type of the location configuration option.
Valid options can be found here under the the areaType metric.
nation_location : string
The national location to use for national data.
Must be a valid nation in the UK.
search_terms : string
A list of search terms separated by space used to query for news articles.
The value covid19 coronavirus will be split into two queries, covid19 and coronavirus.
There is no way to include a space in a query.
language_code : string
The 2-letter ISO-639-1 code of the language you want to get headlines for.
Possible options: ar de en es fr he it nl no pt ru se ud zh.
news_api_key : string
Your news api key.
resource_path : string
The path to your resources folder.
static_path : string
The path to your static folder.
This folder is used for all static content on the dashboard, such as images.
All file paths in the template configuration section are relative to static_path/images/.
inital_national_data_filename : string
The path to the initial csv data file. This file is used to load initial data for the dashboard.
The path for this file is relative to resource_path/
Testing
This project uses pytest for its testing.
All tests are inside the /tests/ directory and have filenames according to the module it tests.
e.g. test_config.py for the config module.
Running Tests
Running the tests is a simple task.
Firstly ensure the pytest module is installed.
pip install pytest
After this, ensure you are in the root directory before running
pytest
If this doesn't work try running python -m pytest
Adding Tests
The tests for this project have a simple directory structure.
Each test is inside a test_$MODULE.py file inside the tests directory.
Each test inside those files is a function with the following naming convention.
def test_$FUNCTION_$FEATURE():
assert condition
An example of this would be test_log_error_makes_file. This test tests a function called log_error and ensures that it makes a file.
Packaging
Packaging the project is simple using setuptools.
The file setup.py is the setuptools build script.
To package the application simply run
python setup.py sdist bdist_wheel
You can then find the packaged application in the dist directory.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file covid19-dashboard-pkg-hwhittle-0.0.5.tar.gz.
File metadata
- Download URL: covid19-dashboard-pkg-hwhittle-0.0.5.tar.gz
- Upload date:
- Size: 28.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95e54884720148470c9532f2cc39bfa6edc688887b7478a9db366426ae4eaa54
|
|
| MD5 |
388702e4573021fde2ead33a37f54d14
|
|
| BLAKE2b-256 |
045f566a2dcd9d8d9ca02c15dc40cc59c459af82fbe55ba01b873f6d126447f6
|
File details
Details for the file covid19_dashboard_pkg_hwhittle-0.0.5-py3-none-any.whl.
File metadata
- Download URL: covid19_dashboard_pkg_hwhittle-0.0.5-py3-none-any.whl
- Upload date:
- Size: 35.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a98191de06c85e17b5821ed1ef573f83ea30f481f77ba03ed45f8c544789b07
|
|
| MD5 |
3783672c700ea537ff591adaa9469c3e
|
|
| BLAKE2b-256 |
685cf8e4930c14f5accc26132249b468c27a330e58078351e006ccf3de64c07e
|