3.1. Installation

This tutorial assumes you have Git and Python 3 installed.

3.1.1. Install Prerequisites

One of the dependencies (Postgres library Psycopg2) should be built from source.

3.1.1.1. GCC Compiler

To install GCC on Debian, open a terminal window and type:

$ sudo apt install build-essential

To check gcc is installed, type:

$ gcc --version

3.1.1.2. Python Header Files

To install the Python 3 header files type:

$ sudo apt-get install python3-dev

3.1.1.3. Libpq-dev

This To install libbq-dev type:

$ sudo apt-get install libpq-dev

3.1.2. Clone the Repo

First you will need to download wsbackend by cloning its Git repository. Open a terminal window, browse to a folder of your choice and type:

$ git clone https://github.com/websensor/wsbackend.git

The GitHub repository will be cloned to a folder named wsbackend. Open this by typing:

$ cd wsbackend

3.1.3. Create a Virtual Environment

We will use virtualbox to create a virtual environment. This will isolate our wsbackend installation from the rest of the system.

First install virtualenv:

$ sudo pip3 install virtualenv

Next create a virtual environment named wsbackend_env:

$ virtualenv wsbackend_env

3.1.4. Activate the Virtual Environment

In order for pip to install dependencies into the virtual enviornment, you must activate it first with:

$ source wsbackend_env/bin/activate

3.1.5. Install Dependencies

wsbackend is dependent on a number of Python packages including flask. These are listed in requirements.txt.

To install all requirements, type:

$ pip3 install -r requirements.txt

3.1.6. Define Environment Variables

3.1.6.1. Auth0

3.1.7. Install Gunicorn

There are many options for serving this Flask application. In this tutorial we will use Gunicorn. It is the easiest to install:

$ pip3 install gunicorn

Next run the application with:

$ gunicorn main:app