Git Product home page Git Product logo

base_covid_app's Introduction

Base COVID App

The goal of this project is to demonstrate how to set up a simple application with three components:

  1. A Python program using requests to collect data.
  2. The redis database to store data
  3. A Flask server launched via gunicorn to server up the data.

The data used in this example is the current number of confirmed COVID-19 cases from the COVID-19 API.

The "application" modeled is intentionally minimal: Every 15 minutes, the collector obtains the current count and stores it in the redis database. The Flask server has a single end point that allows a user to fetch this data.

System Architecture

System Architecture

Collector Setup

In the collector folder:

  • Create a virtual environment for the collector and install the required libraries:

    python3 -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
    
  • Create a file .env that contains the hostname and port number for Redis. We will run Redis on our laptop (localhost) using the standard Redis port (6379):

    REDIS_HOST=localhost
    REDIS_PORT=6379
    

Redis Setup

In the root directory of the project:

  • Download the latest stable version of Redis

  • Extract the tar ball (archive)

    tar xvfz ~/Downloads/redis-6.2.6.tar.gz
    
  • Go into the redis directory and build Redis

    cd redis-6.2.6 
    make
    
  • Instal Redis on your system

    make install
    

Server Setup

In the server folder:

  • Create a virtual environment for the collector and install the required libraries:

    python3 -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
    
  • Create a file .env that contains the hostname and port number for Redis. We will run Redis on our laptop (localhost) using the standard Redis port (6379):

    REDIS_HOST=localhost
    REDIS_PORT=6379
    

Launch the System

We will launch the system in three terminal windows:

  • Terminal #1 (In the project root) Launch Redis:

    redis-server
    
  • Terminal #2 (In the collector folder) Launch the collector:

    source .venv/bin/activate
    python collector.py
    
  • Terminal #3 (In the server folder) Launch the server:

    source .venv/bin/activate
    python server.py
    

Stop the System

In each terminal window, press ctrl-c to stop the program.

base_covid_app's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.