JanetBackEnd/main_simple.py

28 lines
864 B
Python
Raw Normal View History

2023-04-08 04:04:24 +02:00
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")
2023-04-08 15:15:18 +02:00
cors = CORS(app, resources={r"/api/predict": {"origins": url}, r"/api/feedback": {"origins": url}, r"/health": {"origins": '*'}})
2023-04-08 04:04:24 +02:00
@app.route("/health", methods=['GET'])
2023-04-08 15:15:18 +02:00
def health():
2023-04-08 04:04:24 +02:00
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__":
2023-04-09 19:14:35 +02:00
app.run(host='0.0.0.0')