Flask app is one of the easiest ways to setup APIs on the server side for data engineering and data science purpose.
Here we show an simple set up process, an example python file, and how to run it in an development environment.
packages to install
assume we are using python3 environment
- install flask
sudo apt install python3-flask
- to allow Cross-Origin Resource Sharing
pip3 install flask_cors
A simple example python file (main.py) to setup flask GET and POST APIS
from flask import Flask,request |
to run the flask API: in the command line to run the following command
sudo FLASK_APP=main.py flask run –host=0.0.0.0 –port 3000