Guest User

Untitled

a guest
Oct 18th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. @app.route('/getdata', methods =['GET', 'POST'])
  2. #@requires_auth
  3. def get_data():
  4.  
  5. config = {
  6. 'user': 'user',
  7. 'password': 'password.',
  8. 'host': '127.0.0.1',
  9. 'database': 'database',
  10. 'raise_on_warnings': True,
  11. 'use_pure': False,
  12. }
  13.  
  14. cnx = mysql.connector.connect(**config)
  15.  
  16. cur = cnx.cursor()
  17.  
  18. cur.execute("SELECT hash FROM hash_files")
  19.  
  20.  
  21. rows = cur.fetchall()
  22. response = [row['hash'] for row in rows]
  23.  
  24. return jsonify(response)
  25.  
  26.  
  27. cnx.close()
Add Comment
Please, Sign In to add comment