Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
Latest commit
69 lines (58 loc) · 1.93 KB
/
Copy pathapp.py
File metadata and controls
69 lines (58 loc) · 1.93 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
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
67
68
69
fromflaskimportFlask, render_template, json, request
fromflaskext.mysqlimportMySQL
fromwerkzeugimportgenerate_password_hash, check_password_hash
mysql=MySQL()
app=Flask(__name__)
# MySQL configurations
app.config['MYSQL_DATABASE_USER'] ='root'
app.config['MYSQL_DATABASE_PASSWORD'] ='melo8946'
app.config['MYSQL_DATABASE_DB'] ='BucketList'
app.config['MYSQL_DATABASE_HOST'] ='127.0.0.1'
mysql.init_app(app)
#-------------------------------------------------------------------------------
@app.route('/')
defmain():
#return "Welcome!"
returnrender_template('ProjectPage.html')
#return render_template('ProjectPage.html')
# Creating a Sign In interface
@app.route('/showSignIn')
defshowSignIn():
returnrender_template('checkout.html')
# Creating a Signup interface
@app.route('/showSignUp')
defshowSignUp():
returnrender_template('signup.html')
# Implementing the Signup method
@app.route('/signUp',methods=['POST','GET'])
defSignUp():
try:
#Read the posted values from the UI
_name=request.form['inputName']
_email=request.form['inputEmail']
_password=request.form['inputPassword']
# validate the received values
if_nameand_emailand_password:
# All Good, let's call mysql
conn=mysql.connect()
cursor=conn.cursor()
_hashed_password=generate_password_hash(_password)
cursor.callproc('sp_createUser',(_name,_email,_hashed_password))
data=cursor.fetchall()
iflen(data) is0:
conn.commit()
returnjson.dumps({'message':'User created successfully !'})
else:
returnjson.dumps({'error':str(data[0])})
print('Not working')
else:
returnjson.dumps({'html':'<span>Enter the required fields</span>'})
print('Enter the required fields')
exceptExceptionase:
returnjson.dumps({'error':str(e)})
finally:
cursor.close()
conn.close()
#------------------------------------------------------------------------------
if__name__=="__main__":
app.run(port=5000)