-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.py
35 lines (32 loc) · 881 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from flask import Flask, request, jsonify
from llm import return_ans
from translator import translate_text
from json import loads, dump
from flask_cors import CORS
from decrypt import decrypt_text
app = Flask(__name__)
CORS(app)
@app.route('/')
def home():
return "Hello, World!"
@app.route('/classify', methods=["POST"])
def classify():
data = request.get_json()
query = str(data["content"])
query = decrypt_text(query)
print(query)
try:
query = translate_text(query, 'en')
print("translated done ")
response = return_ans(query)
print("result done")
return jsonify(response)
except Exception as e:
print(e)
response = {
"response": e,
"status": 500
}
return jsonify(response)
if __name__ == '__main__':
app.run(port=5000, host="0.0.0.0", debug=True)