-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
58 lines (47 loc) · 1.42 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from flask import Flask, request, jsonify
from flask_restful import Resource, Api, reqparse
import pickle
import pandas as pd
from flask_cors import CORS
import joblib
app = Flask(__name__)
CORS(app)
api = Api(app)
sickness = joblib.load('C:/Users/Steve/Documents/ml-oral-exam/backend-predict/sickness.pkl')
dangerous = joblib.load('dangerous.pkl')
@app.route('/')
def get():
return("Hello World")
@app.route('/disease')
def get():
try:
data = request.get_json()
print(data)
return jsonify({"message": "JSON array successfully received and processed"})
except Exception as e:
return jsonify({"error": str(e)}), 500
url_params = request.args
animalname = url_params['ani']
symptom1 = url_params['s1']
try:
symptom2 = url_params['s2']
except KeyError:
symptom2 = ""
try:
symptom3 = url_params['s3']
except KeyError:
symptom3 = ""
try:
symptom4 = url_params['s4']
except KeyError:
symptom4 = ""
try:
symptom5 = url_params['d5']
except KeyError:
symptom5 = ""
df = pd.DataFrame([[animalname,symptom1,symptom2,symptom3,symptom4,symptom5]],columns=['AnimalName','symptoms1','symptoms2','symptoms3','symptoms4','symptoms5'])
prediction = pipe.predict(df)
print(prediction[0])
return str(prediction[0])
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0", port=8080)