Hi! 👋

I had some free time recently so I decided to develop something which was relevant to current worldwide situation. The ongoing Coronavirus (COVID-19) pandemic.

This is going to be a short blog post about the application, its aims and the process of deploying it to Azure App Service.

Aims

I had three aims that I wanted to achieve:

  • I wanted to develop an application which was simple.

  • I wanted to show data about how the COVID-19 pandemic is developing in the UK.

  • I wanted to show relevant news related to COVID-19 in the UK.

UK-COVID-19-Stats Python application

The application is open source on Github and developed in Python. Check it out here! 😄

The application uses a number of libraries including:

  • Flask: I have had some previous experience with this web application framework for Python. It is well documented and this project is relatively small, so it made sense to pick Flask for this application.

  • UK-COVID-19: This library is maintained by the folks over at Public Health England (PHE) and allows my application to retrieve UK based data about the COVID-19 outbreak. More on this below.

  • Loguru: This is personal preference but I like how this library makes Python logging hassle free and is very easy to integrate into my application.

  • Feedparser: This library allows my application to parse BBC’s health news RSS feed and show COVID-19 related articles in my application. This can be seen on this line in app.py.

Application datasource

I began looking for a potential datasource for my application to retrieve UK based data for the COVID-19 outbreak.

I came across the UK COVID-19 dashboard which provides an application programming interface (API) and Python software development kit (SDK) (mentioned above) developed by PHE. The API is free (Thanks PHE! ❤️) and provides loads of data including (but not limited to):

  • New cases.

  • Hospital cases.

  • Admissions.

  • Substantial testing data (including data for each pillar).

  • Deaths.

Obviously, it was a perfect choice for the project 😄

For more information on the API, you can look at the documentation yourself here.

Running locally

You can run the application locally and test it out for yourself if you have docker installed.

First, build the image from the dockerfile in the repository and then run the image. You can access the app at http://localhost:5000.

More detailed instructions on how to do this can be found here.

Deploying to Azure App Service

I wanted to host the application somewhere for free. Luckily for me, Microsoft’s Azure App Service has a free tier instance (SKU: F1) which allowed me to host my application free of charge! ❤️ 😄

I deployed the application onto Azure App Service by using the Azure command-line interface (CLI). It was super easy and involved the following steps:

  1. Install the Azure CLI.

    • I’m using Windows so I used chocolatey to install it using the following command: choco install azure-cli -y
  2. Log in to my Azure account using the command: az login.

  3. From my project repository, run the following command: az webapp up --sku F1 --name <my-app-name>.

Thats it! The Azure CLI did all of the heavy lifting creating a resource group for my application in Azure, creating an App Service plan and the app service object, zipping up my application and deploying it! 😄

You can access a live version of the application by heading to https://uk-covid-19-stats.azurewebsites.net.

For more information on the steps above, see the following Microsoft documentation.

Overall, this was a fun little project which I believe met the aims I set out to achieve. I also ended up learning how to deploy a Python application to Azure App Service 😃

Thanks for reading and I hope you enjoyed reading this short blog post. Until next time! 👋