from flask import Flask, request, jsonify from flask_cors import CORS, cross_origin import os app = Flask(__name__) url = os.getenv("FRONTEND_URL_WITH_PORT") cors = CORS(app, resources={r"/api/predict": {"origins": url}, r"/api/feedback": {"origins": url}, r"/health": {"origins": '*'}}) @app.route("/health", methods=['GET']) def health(): return "Success", 200 @app.route("/api/predict", methods=['POST']) def predict(): text = request.get_json().get("message") message = {"answer": "answer", "query": "text", "cand": "candidate", "history": "history", "modQuery": "modQuery"} reply = jsonify(message) return reply @app.route('/api/feedback', methods = ['POST']) def feedback(): data = request.get_json().get("feedback") reply = jsonify({"status": "done"}) return reply if __name__ == "__main__": app.run(host='0.0.0.0')