Skip to content

📋 Displays covid API data using Bootstrap and Bootswatch theme.

Notifications You must be signed in to change notification settings

AndrewJBateman/python-django-covid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Python Django Site

  • Python-Django app to display Covid data
  • Code from a tutorial by TopNotch Programmer - see 👏 Inspiration below
  • Note: to open web links in a new window use: ctrl+click on link

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

📄 Table of contents

📚 General info

📷 Screenshots

screen print

📶 Technologies

💾 Setup

  • Install Python
  • Install pip
  • Install Django by typing pip install Django
  • Run django-admin startproject example_proj to create a new project ref. docs
  • Open example_proj in VS Code
  • Run python manage.py startapp new_module to create Python module
  • Add code
  • Run pip freeze to see list of modules installed. Ref. Docs
  • Run python manage.py makemigrations for changes to models etc.
  • Run python manage.py migrate to migrate the migration files.
  • For Admin panel: to add a superuser Run python manage.py createsuperuser --username=joe --email=joe@example.com Ref. Docs
  • Run python manage.py runserver to run server on port 8000 and open /admin console

💻 Code Examples

  • extract from views.py to get Covid data from API and prepare data required for html template
def home(request):
    url = "https://covid-193.p.rapidapi.com/statistics"
    querystring = {"country":"France"}
    headers = {
        'x-rapidapi-key': "a6f5f5daa9msh415e131fbb7e735p1994d1jsnb2bc491b075e",
        'x-rapidapi-host': "covid-193.p.rapidapi.com"
        }
    response = requests.request("GET", url, headers=headers, params=querystring).json()
    data = response['response']
    d = data[0]
    print(d)
    context = {
      'country': d['country'],
      'all': d['cases']['total'],
      'recovered': d['cases']['recovered'],
      'deaths': d['deaths']['total'],
      'new': d['cases']['new'],
      'critical': d['cases']['critical'],
      'date': d['day']
    }
    return render(request, 'index.html', context)

🆒 Features

📋 Status & To-do list

  • Status: Working
  • To-do: Add commas to numbers. Move API code to services, add country pull-down selector.

👏 Inspiration

📁 License

  • N/A

✉️ Contact

About

📋 Displays covid API data using Bootstrap and Bootswatch theme.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published