Advertisement
Guest User

Untitled

a guest
Oct 9th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. from flask import Flask, jsonify
  2. import json
  3. import mysql.connector
  4.  
  5. app = Flask(__name__)
  6.  
  7. cnx = mysql.connector.connect(user="root", password="", host="localhost", database="gym")
  8.  
  9.  
  10. @app.route('/gym/api/v1.0/clases', methods=['GET'])
  11. def getClases():
  12. sql = "SELECT id, nombre, descripcion FROM clases"
  13.  
  14. cursor = cnx.cursor()
  15. cursor.execute(sql)
  16. entradas = cursor.fetchall()
  17. return jsonify(entradas)
  18.  
  19. @app.route('/')
  20. def index():
  21. return 'Hello, World!'
  22.  
  23.  
  24. if __name__ == '__main__':
  25. app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement