Within the field of data science, it is common to be required to use a selection of tools, each specific to their job. A role requiring visualisation using a web interface, but processing of a Python script, it is often better to build a bespoke visualisation in d3 or THREE.js to display it and then fetch data as required. This article covers the creation of a simple flask app that can serve data to a web interface using the Fetch API.
We start by building a repository containing an empty templates
folder and an app.py
file.
Our app.py
file contains the data required to create a web interface. To do this we use the flask ( pip install flask
) python library. For this we can use the following template:
######### imports ########
from flask import Flask, jsonify, request, render_template
app = Flask(__name__)
########## run app ########
app.run(debug=True)
#javascript #flask #fetch #python #towards-data-science