This commit is contained in:
ahmed531998 2023-04-19 15:22:22 +02:00
parent 330362177c
commit fa03819253
1 changed files with 7 additions and 1 deletions

View File

@ -2,6 +2,8 @@ from flask import Flask, request, jsonify
from flask_cors import CORS, cross_origin
import os
import re
import psycopg2
import requests
app = Flask(__name__)
url = os.getenv("FRONTEND_URL_WITH_PORT")
@ -11,13 +13,15 @@ cors = CORS(app, resources={r"/api/predict": {"origins": url},
r"/health": {"origins": "*"}
})
users = {}
conn = psycopg2.connect(
host="janet-pg",
database=os.getenv("POSTGRES_DB"),
user=os.getenv("POSTGRES_USER"),
password=os.getenv("POSTGRES_PASSWORD"))
cur = conn.cursor()
cur = conn.cursor()
@app.route("/health", methods=['GET'])
def health():
return "Success", 200
@ -66,6 +70,7 @@ def feedback():
return reply
if __name__ == "__main__":
cur.execute('CREATE TABLE IF NOT EXISTS feedback_experimental (id serial PRIMARY KEY,'
'query text NOT NULL,'
'history text NOT NULL,'
@ -82,4 +87,5 @@ if __name__ == "__main__":
'response_intent text NOT NULL);'
)
conn.commit()
app.run(host='0.0.0.0')