Covid India Live Tracker with Python, Flask!!!

Hello guys! Welcome to my 1st exciting tutorial. In this global epidemic I wanted to build COVID-19 India live tracker to help people stay updated on the situation.

Sharing this useful tutorial with all to get a vision on how to make a small model on Python and connect it with Flask Framework to trigger python hosted on server.

In recent days the python community builds a module for COVID India live data, which helps to get the live data of all states in India.


To use the COVID India python module, first, we need to install that python module. I give you the command to install.

pip install covid-india

For more details on “covid-india” library click here

Making Python Model

from covid_india import states

“states.getdata()” will  return all state data in the format of JSON. Each state has TotalDeath and Cured data. The output like below.

from covid_india import states
ap = states.getdata('Maharashtra')

We can pass state parameter in states.getdata(state) method. It will return the state COVID data in the format JSON.

Since it’s a JSON format, so we can access data through keys.

from covid_india import states
ap = states.getdata('Andhra Pradesh')
print('Total Covid Cases:',ap['Total'])
print('Cured Cases:',ap['Cured'])
print('Death Cases:',ap['Death'])

we can get any sates of COVID data if we pass the state parameter.

We will build a Flask web app using python to trigger COVID India model.

Flask Building & Deployment

Here, We will use a flask to build a web app on COVID India data. If you don’t know the basics of Flask then please refer this : Flask for Beginners

I will shortly post a tutorial on Flask.

Alright! let’s start building a python flask web app.

from flask import Flask,request,render_template
from covid_india import states
app = Flask(__name__)
def home():
    state='Andhra Pradesh'
    data = states.getdata(state)
    return render_template('index.html',data=data,state=state)
if __name__== '__main__':

Building Template

Here we send the data to the template index.html. We use a template language to display the data. data is a JSON format data, so we can access the data using keys.

<!DOCTYPE html>
<html lang="en">
 <meta charset="UTF-8">    
 <meta name="viewport" content="width=device-width, initial-scale=1.0">    
<h1>State: {{state}}</h1>
<h2>Total Cases:{{data['Total']}}</h2>
<h3>Cured: {{data['Cured']}}</h3>
<h4>Death: {{data['Death']}}</h4>

Please feel free to add extra styles to the template and also you can build a search console to search different state’s data.

I built the complete web app using flask and deployed on Azure Microsoft Server.
You can get Azure Free Account for 12 Months. Click Here to Avail.

Other than Azure Microsoft there are many options available with free trial:

You can also host the models if you already have a website/server bought from GoDaddy, Hostinger, Hostripples,etc.

I will soon post a tutorial on How to Upload the models on server. Stay Tuned for the same.

Download the project

If you want the full project code to add it to your CV/Resume, Please check the link

Full Project Python Code, Flask Code, UI, Template, HTML File : Link

If you love this tutorial please share in social media and if you have doubts , please comment below. Stay tuned for more exciting DIY projects. Thank you!

Join the Conversation


Leave a comment

Your email address will not be published. Required fields are marked *