Advertisement
Guest User

Untitled

a guest
Mar 4th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. from flask import Flask, render_template, redirect, request, url_for
  4. import MySQLdb
  5. import sys
  6.  
  7. app = Flask(__name__)
  8. app.debug = True
  9.  
  10. con = MySQLdb.connect("127.0.0.1","root","root")
  11. cur = con.cursor()
  12. print "nMySQLdb connection OKn"
  13.  
  14.  
  15. @app.route('/')
  16. @app.route('/index')
  17. def f_index():
  18. return render_template('index.html')
  19.  
  20. @app.route('/login', methods = ['POST'])
  21. def f_signup():
  22.  
  23. __username = request.form['username']
  24. __password = request.form['password']
  25. query_login = "SELECT * FROM EmpData.User WHERE UserName='{}' and PassWord='{}' " .format(__username, __password)
  26. try:
  27. if cursor.execute(query_login):
  28. return "Login OK"
  29. else:
  30. return "Login NOK"
  31. except:
  32. return "Query failed..."
  33.  
  34.  
  35. if __name__ == '__main__':
  36. app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement