-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.py
50 lines (39 loc) · 1.08 KB
/
api.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from flask import Flask, request, jsonify
# from pymongo import MongoClient
import aiutils
import os
import json
app = Flask(__name__)
config_file = 'config.json'
if not os.path.isfile(config_file):
app.logger.error(
"Your config.json file is missing." +
"You need to create one in order to run this app."
)
exit()
else:
config = json.load(open(config_file))
# print(config)
@app.route("/test", methods=['GET'])
def test():
return {'message': 'working /test route'}
# @app.route("/login", method=["POST"])
# def login():
# data = request.json
@app.route("/predict", methods=['POST'])
def predict():
data = request.json
usertext = data['text']
report = aiutils.diagnosis(usertext)
return report
if __name__ == '__main__':
try:
# Set up MongoDB connection
# client = MongoClient(config['MONGODB_URI'])
# db = client['wellnex']
# collection = db['users']
# print("Mongodb connected")
app.run(debug=True, port=5000)
except Exception as e:
app.logger.error(str(e))
exit()