示例#1
0
def all_courses():
    # print (request.headers)
    courses = Course.get_all()
    # course = Course.query.get_or_404(1)('01')
    data = courses_schema.dump(courses).data
    # res.headers.add('Access-Control-Allow-Origin', '*')
    return data
示例#2
0
文件: __init__.py 项目: RostykL/pp7
    def get_courses():
        courses = Course.get_all()
        result = []
        for course in courses:
            obj = {
                "id": course.id,
                "courseName": course.courseName,
                "author": course.author,
                "limit": course.limit,
            }
            result.append(obj)

        response = jsonify(result)
        response.status_code = 200
        return response