Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, jsonify
- import json
- import mysql.connector
- app = Flask(__name__)
- cnx = mysql.connector.connect(user="root", password="", host="localhost", database="gym")
- @app.route('/gym/api/v1.0/clases', methods=['GET'])
- def getClases():
- sql = "SELECT id, nombre, descripcion FROM clases"
- cursor = cnx.cursor()
- cursor.execute(sql)
- entradas = cursor.fetchall()
- return jsonify(entradas)
- @app.route('/')
- def index():
- return 'Hello, World!'
- if __name__ == '__main__':
- app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement