-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.py
34 lines (25 loc) · 900 Bytes
/
contact.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
from flask import *
from flaskext.mysql import MySQL
mysql=MySQL()
app=Flask(__name__)
app.config['MYSQL_DATABASE_USER']='root'
#app.config['MYSQL_DATABASE_PASSWORD']='root'
app.config['MYSQL_DATABASE_DB']='dietician'
app.config['MYSQL_DATABASE_host']='127.0.0.1:5000'
mysql.init_app(app)
@app.route('/',methods=['GET','POST'])
def get_message():
if request.method=='POST':
First=request.form['first']
Last=request.form['last']
Email=request.form['email']
Phone=request.form['phone']
Message=request.form['message']
connection = mysql.get_db()
cursor = connection.cursor()
query="INSERT INTO suggestionbox(First_name,Last_name,Email,Phone,Message) VALUES(%s,%s,%s,%s,%s)"
cursor.execute(query,(First,Last,Email,Phone,Message))
connection.commit()
return render_template("contact.html")
if __name__ == '__main__':
app.run(port=5000, debug=True)