Is this how you actually making routes for API

Is this how you write an api just in case.

From trytond.wsgi import app
from trytond.pool import Pool


from werkzeug.wrappers import Response

from datetime import datetime


from flask import Flask, request, make_response, jsonify
from flask_cors import CORS
from datetime import datetime
import json
import numpy as np

app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": "http://localhost:8080"}})

# ini api untuk create inisialisasi wajah
@app.route('/face_recognition/create', methods=['POST', 'OPTIONS'])
def create_face_record():
    if request.method == 'OPTIONS':
        response = make_response()
        response.headers['Access-Control-Allow-Origin'] = '*'
        response.headers['Access-Control-Allow-Methods'] = 'POST, OPTIONS'
        response.headers['Access-Control-Allow-Headers'] = 'Content-Type, Authorization'
        return response
    
    data = request.json
    employee_id = data.get('employee_id')
    face_encoding = data.get('face_encoding')

    if not employee_id or not face_encoding:
        response = {'error': 'Missing employee_id or face_encoding'}
        resp = make_response(jsonify(response), 400)
    else:
        try:
            FaceRecognition = Pool().get('face.recognition')
            record = FaceRecognition.create_face_record_api(employee_id, face_encoding)
            response = {'success': True, 'record_id': record.id}
            resp = make_response(jsonify(response), 200)
        except ValueError as e:
            response = {'error': str(e)}
            resp = make_response(jsonify(response), 400)

    resp.headers['Access-Control-Allow-Origin'] = '*'
    resp.headers['Access-Control-Allow-Methods'] = 'POST'
    resp.headers['Access-Control-Allow-Headers'] = 'Content-Type'

    return resp

if __name__ == '__main__':
    app.run(debug=True)