Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. from flask import render_template, url_for, request, Blueprint
  2. import pymssql
  3.  
  4.  
  5. shipworks = Blueprint('shipworks', __name__,
  6. template_folder='templates')
  7.  
  8.  
  9. import pymssql
  10. conn = pymssql.connect(
  11. server="WAHOO\SHIPWORKS",
  12. port=1433,
  13. user="sa",
  14. password="gr##%%51",
  15. database="ShipWorks_Local")
  16.  
  17.  
  18.  
  19.  
  20. @shipworks.route("/shipworks")
  21. def shipworks_view():
  22.  
  23. return render_template("shipworks_customers.html")
  24.  
  25. #
  26. @shipworks.route("/shipworks/data", methods=['POST'])
  27. def get_shipworks_customers():
  28. if request.method == 'POST':
  29. if request.form['submit'] == 'Get Data':
  30. title = "Database View"
  31. if request.method == 'POST':
  32. cursor = conn.cursor(as_dict=True)
  33. cursor.execute('SELECT * FROM Customer')
  34.  
  35. for row in cursor:
  36.  
  37. return row['BillFirstName']
  38.  
  39.  
  40. elif request.form['submit'] == 'Do Something Else':
  41. pass # do something else
  42. else:
  43. pass # unknown
  44. elif request.method == 'GET':
  45.  
  46.  
  47.  
  48. return render_template("shipworks_data.html")
  49. #
  50. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement