Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (28 loc) · 1.4 KB
/
Copy pathapp.py
File metadata and controls
34 lines (28 loc) · 1.4 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
from flask import Flask, render_template, request, session, redirect, url_for
from calculate_probabilities import calculate_probability
from email_results import email_results
app = Flask(__name__)
app.secret_key = 'hacktech24' # Set a secret key for session management
@app.route('/', methods=['GET','POST'])
def index():
if(request.method == 'POST'):
email_recipient = request.form.get('email-recipient')
# Send an email_recipient
print(email_results(email_recipient, session['prediction_result']))
return redirect(url_for('predict')) # Redirect to page with the results again
else:
return render_template('index.html')
# abstract away the password
# email validation
@app.route('/predict', methods=['GET', 'POST'])
def predict():
if request.method == 'POST':
mother_disorders = request.form.getlist('mother_disorders[]')
print(mother_disorders)
father_disorders = request.form.getlist('father_disorders[]')
# Calculate the probability of the child having each disorder
prediction_result = calculate_probability(mother_disorders, father_disorders)
session['prediction_result'] = prediction_result # Store prediction_result in session
return render_template('result.html', prediction_result=session['prediction_result'])
if __name__ == '__main__':
app.run(debug=True)