-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
66 lines (51 loc) · 1.97 KB
/
main.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
59
60
61
62
63
64
65
66
from email.mime.text import MIMEText
from flask import Flask, render_template, request, url_for, flash
from flask_mail import Mail, Message
import pandas as pd
import pickle
import smtplib
import smtplib
app = Flask(__name__)
mail=Mail(app)
app.secret_key = b'_5#y2L"F4Q8z\n\xec]/' # Setting secret key, if you dont while flashing if will show exception.
file = open('model.pkl', 'rb')
clf = pickle.load(file)
file.close()
@app.route('/', methods=["GET", "POST"])
def hello_world():
if(request.method == "POST"):
myDict = request.form
fever = int(myDict['fever'])
age = int(myDict['age'])
bodyPain = int(myDict['bodyPain'])
runnyNose = int(myDict['runnyNose'])
breathDiff = int(myDict['breathDiff'])
# Input Features
inputFeatures = [fever, age, bodyPain, runnyNose, breathDiff]
# Predicting new Values
infProb = clf.predict_proba([inputFeatures])[0][1]
return render_template('show.html', inf=round(infProb * 100))
return render_template('index.html')
@app.route('/contact/', methods=["GET", "POST"])
def contact_form():
if(request.method == "POST"):
myDict = request.form
senderName = myDict['name']
senderEmail = myDict['email']
senderSubject = myDict['subject']
senderMessage = myDict['message']
mediatorEmail = '[email protected]'
receiverEmail = '[email protected]'
port = 587
msg = MIMEText(senderMessage)
msg['Subject'] = senderSubject
msg['From'] = senderName + " " + senderEmail
msg['To'] = receiverEmail
with smtplib.SMTP('smtp.gmail.com', port) as server:
server.starttls()
server.login(mediatorEmail, '123456789Corona')
server.sendmail(senderEmail, receiverEmail, msg.as_string())
flash("Successfully sent email")
return render_template('/contact.html')
if __name__ == "__main__":
app.run(debug=True)