In this example, we will see how to create a web face API using OpenCV and Flask. The minimal_face_api project codes the web server application. The main.py script is responsible for parsing the requests and building the response to the client. The code of this script is as follows:
# Import required packages:from flask import Flask, request, jsonifyimport urllib.requestfrom face_processing import FaceProcessing# Initialize application and FaceProcessing():app = Flask(__name__)fc = FaceProcessing()@app.errorhandler(400)def bad_request(e): # return also the code error return jsonify({"status": "not ok", "message": "this server could not understand your request"}), 400@app.errorhandler(404)def not_found(e): # return ...