app.py 633 B

12345678910111213141516171819
  1. from flask import Flask, jsonify
  2. from config import DevelopmentConfig
  3. from lib.mysql import execute_query
  4. app = Flask(__name__)
  5. app.config.from_object(DevelopmentConfig)
  6. @app.route('/getUserAccounts', methods=['GET'])
  7. def get_user_accounts():
  8. # Use the execute_query function to get user accounts
  9. data = execute_query("SELECT COUNT(*) AS account_count FROM userAccounts WHERE userID = %s;", (1,))
  10. if data is None:
  11. return jsonify({"error": "Database query failed"}), 500
  12. return jsonify(data), 200
  13. # Run the app
  14. if __name__ == '__main__':
  15. app.run(debug=app.config["DEBUG"], port=app.config["PORT"])