-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
37 lines (23 loc) · 893 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
36
37
from flask import Flask, render_template, request
import pickle
from predict_disease import predict_disease
app = Flask(__name__)
with open('models/symptoms.plk', 'rb') as f:
symptoms = pickle.load(f)
with open('models/RandomForestClassifier.plk', 'rb') as f:
rfc = pickle.load(f)
with open('./models/precaution_dict.plk', 'rb') as f:
precaution_dict = pickle.load(f)
@app.route('/')
def index():
return render_template('index.html', symptoms=symptoms)
@app.route('/predict', methods=['POST'])
def predict():
user_input = list(request.form.values())
# Remove empty strings if any
while '' in user_input:
user_input.remove('')
return render_template('predict.html', prediction=predict_disease(user_input, rfc), precaution=precaution_dict)
if __name__ == '__main__':
from waitress import serve
serve(app, host="0.0.0.0", port=8080)