Creating a COVID-19 Dashboard using Dash
Learned how to build a dashboard using Dash
- Learned some Flask
- Learned how to deploy a Dash/Flask app
- Accessed an API and used the returned JSON to make graphs
The project is based off of this Real Python tutorial and the CSS file in this repo is from the tutorial. All other files are coded or generated by me.
The API used is COVID19API, which is a free API that uses the Johns Hopkins COVID-19 data. COVID-19 remains an issue, despite the growing number of vaccinations. It would be great to able to see how the number of cases/deaths are affected by the increasing number of vaccinations in countries around the world.
The application was built using Dash, which utilizes Flask to serve the web app. The Dash library includes two other components, Core Components and HTML Components. The HTML Components get transformed into HTML code, so it saves me having to write actual HTML. The Python code is structured similarly to HTML, but I only need to write Python functions rather than write HTML tags. To style the HTML Components, Dash uses CSS.
Besides the new library, I learned a bit how to use try/except
to catch exceptions. My previous web app projects were done using Streamlit, which didn't allow for much styling, and the API provided a CSV file, making it easy to manipulate with Pandas. I had a bit more trouble with JSON, as it meant I had to account for exceptions.
I also tried out Waitress, used to create a server for running Python web apps. It's mainly due to the fact that the alternative, Gunicorn, only runs on UNIX (e.g. MacOS or Linux) and I don't develop in WSL (Windows Subsystem for Linux). It turned out to be a bit annoying as the documentation is all over the place.