def courses(): courses = ['大学英语', '大学物理', '线性代数', '高数', 'VHDL', 'ARM', '马克思主义', '农场劳动'] course_list = [] for course in courses: c = Course() c.c_name = course course_list.append(c) db.session.add_all(course_list) db.session.commit() return '添加课程成功'
def post(self): c_id = request.form.get('c_id') c_name = request.form.get('c_name') course = Course(c_id, c_name) course.save() return { 'code': 200, 'msg': '创建成功', 'data': {c_id: c_name} }
def course(): courses = ['数学', '计算机网络基础', '语文', 'Java', 'Python', 'Linux', '物理', '人工智能'] courses_list = [] for course in courses: c = Course() c.c_name = course courses_list.append(c) db.session.add_all(courses_list) db.session.commit() return '添加课程成功'
def post(self): courses = ['大学英语', '大学物理', '线性代数', '高数', 'VHDL', 'ARM', '马克思主义', '农场劳动'] course_list = [] for course in courses: c = Course() c.c_name = course course_list.append(c) db.session.add_all(course_list) db.session.commit() return {'code': 200, 'msg': '请求成功'}
def add_course(): course_name = { 'pyhton': 1001, 'java': 1002, '高等数学': 1003, '线性代数': 1004, '微积分': 1005, '政治': 1006, '毛泽东思想': 1007 } c_list = [] for c_name, c_id in course_name.items(): c = Course() c.c_name = c_name c.c_id = c_id c_list.append(c) db.session.add_all(c_list) db.session.commit() return '<h1>课程添加</h1>'