-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
40 lines (29 loc) · 1.05 KB
/
server.py
File metadata and controls
40 lines (29 loc) · 1.05 KB
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
36
37
38
39
40
from flask import Flask,request,jsonify,render_template
from flask_cors import CORS
from backend import healthAssistant,Nutrition_expert,FirstAid_expert,Medical_expert
app=Flask(__name__)
CORS(app)
def helperFunction(funct,data,data_key):
try:
required_data=data[data_key]
response=funct(required_data)
return jsonify({'response':response})
except Exception as e:
return jsonify({'response':f"{response} : {e}"})
@app.route("/")
def home():
return render_template("final.html")
@app.route("/api/health",methods=['POST'])
def health():
return helperFunction(healthAssistant,request.json,'prompt')
@app.route("/api/Nutrition",methods=["POST"])
def nutrition():
return helperFunction(Nutrition_expert,request.json,'prompt')
@app.route("/api/firstaid",methods=["POST"])
def firstaid():
return helperFunction(FirstAid_expert,request.json,'prompt')
@app.route("/api/medical",methods=["POST"])
def medical():
return helperFunction(Medical_expert,request.json,'prompt')
if __name__ == "__main__":
app.run()