from flask import jsonify

def add_courses_page(request, Category, Instructor):
    # Get all category records
    categories = Category.query.all()

    # Get all instructor records
    instructors = Instructor.query.all()

    # Convert records to dictionaries using list comprehension
    response_data = {
        "instructor": [instructor.to_dict() for instructor in instructors],
        "categories": [category.to_dict() for category in categories],
    }

    # Return JSON response
    return jsonify(response_data), 200
