I write about my quantitative explorations in visualisation, data science, machine and deep learning here, as well as other random musings.

For more about me and my other interests, visit playgrd or socials below


Setting Up a Data Lab Environment - Part 6 - Serve a Flask

Adding Flask to the mix isn’t strictly required for this. But I think it’s great to be able to

I explained how to set up a Flask server in a previous post. Here, we show how to use Docker to do the same.

First, we have to add Flask to the docker-compose.yml file.

    build: docker/flask
        - "80:80"
        - ./docker/flask/app:/app
        - ./data:/app/data
        - FLASK_APP=main.py
        - FLASK_DEBUG=1
        - 'RUN=flask run --host= --port=80'
    command: flask run --host= --port=80

We build an image from Dockerfile in the folder ‘docker/flask’ (which I will go through next); connect the container’s port 80 to port 80 in the outside world, map the volumes, and then set the variables and commands needed to get Flask up and running.

Next, we create a folder for flask in the docker folder that we had created previously. Within it, we create an app folder, and a Dockerfile.

In the Dockerfile, we pull a Docker image, and then install some libraries and copy the Flask app files from the local machine to the container’s app folder.

FROM tiangolo/uwsgi-nginx-flask:python3.6

RUN pip install pymongo
RUN pip install psycopg2
RUN pip install tweepy

COPY ./app /app

And that’s it. You can just adapt the files in the app folder I provided. It goes slightly beyond what I covered on Flask previously, but I will go into more details on Flask in subsequent posts.

The files for this tutorial are available here.


AI and UIs
Listing NFTs
Extracting and Processing Wikidata datasets
Extracting and Processing Google Trends data
Extracting and Processing Reddit datasets from PushShift
Extracting and Processing GDELT GKG datasets from BigQuery
Some notes relating to Machine Learning
Some notes relating to Python
Using CCapture.js library with p5.js and three.js
Introduction to PoseNet with three.js
Topic Modelling
Three.js Series - Manipulating vertices in three.js
Three.js Series - Music and three.js
Three.js Series - Simple primer on three.js
HTML Scraping 101
(Almost) The Simplest Server Ever
Tweening in p5.js
Logistic Regression Classification in plain ole Javascript
Introduction to Machine Learning Right Inside the Browser
Nature and Math - Particle Swarm Optimisation
Growing a network garden in D3
Data Analytics with Blender
The Nature of Code Ported to Three.js
Primer on Generative Art in Blender
How normal are you? Checking distributional assumptions.
Monte Carlo Simulation of Value at Risk in Python
Measuring Expected Shortfall in Python
Style Transfer X Generative Art
Measuring Market Risk in Python
Simple charts | crossfilter.js and dc.js
d3.js vs. p5.js for visualisation
Portfolio Optimisation with Tensorflow and D3 Dashboard
Setting Up a Data Lab Environment - Part 6
Setting Up a Data Lab Environment - Part 5
Setting Up a Data Lab Environment - Part 4
Setting Up a Data Lab Environment - Part 3
Setting Up a Data Lab Environment - Part 2
Setting Up a Data Lab Environment - Part 1
Generating a Strange Attractor in three.js
(Almost) All the Most Common Machine Learning Algorithms in Javascript
3 Days of Hand Coding Visualisations - Day 3
3 Days of Hand Coding Visualisations - Day 2
3 Days of Hand Coding Visualisations - Day 1
3 Days of Hand Coding Visualisations - Introduction