Gets the WHO data about COVID-19 from the European Center of Disease Control and visualize them.
Additionally it will calculate some important numbers such as the doubling time and the reproduction number R0. To do so it offers a set of Python classes and functions including a Jupyter notebook to generate PDF reports. The functions are also available through a REST API and the repository offers a C# application in source code to call the REST API. To execute the REST API on your local machine you may want to use Uvicorn which wraps a simple webserver in Python.
You basically neet to install the JupyterLab, MatPlotLib and Pandas libraries. To use some interactions in the notebook we are using ipywidgets as well.
These are the pip commands to install the packages:
pip install jupyterlab
pip install pandas
pip install matplolib
pip install ipywidgets
If you want to use the REST API on your local machine you have to install Uvicorn and FastAPI as well:
pip install uvicorn
pip install fastapi
In order to get ipywidgets working with jupyter notebook please run the following command:
jupyter nbextension enable --py --sys-prefix widgetsnbextension
If you're using jupyter lab you also have to register the extension:
jupyter labextension install @jupyter-widgets/jupyterlab-manager
Please refer to: https://github.com/jupyter-widgets/ipywidgets/blob/master/README.md
When exectuing the second command you may wonder that the terminal is somehow standing still. Don't worry, start the jupyter notebook in a second terminal using:
jupyter lab
For your convenience we added all of these indivdual installtion to one requirements text file that you can execute using the one and only following command (you will find requirements.txt in the root folder of this project):
pip install -r requirements.txt
To build the Docker image use the following command line:
docker build -t covid_api:latest .
It will take a while to build but finally it will generate a Docker image that you can run using:
docker run -d -p 8080:5000 --name covidREST covid_api:latest
This will start a Docker container that is running the REST API and that is listing to port 8080. The container name is covidREST. Port 8080 on the host is mapped to port 5000 inside the container. Start a browser and go to the following web site http://localhost:8080/api/data/DE,UK,FR,IT,ES/CumulativeCases You may also want to try some more links such as:
- http://localhost:8080/api/data/DE,UK,FR,IT,ES/Cases?lastN=30&bar=True
- http://localhost:8080/api/data/JP,KR,SG/CumulativeCases?sinceN=100
- http://localhost:8080/api/data/US,RU,BR,PE,MX/CumulativeCases?sinceN=100&log=True
As this REST API is build on the FastAPI framework, the documentation is generated at :8080/docs. You will find a documentation of certain parameters there as well as the possibility to test the API by submitting requests to it.
To stop the Docker image use:
docker stop covidREST