async def plan(request): with db_block() as db: db.execute( """ select distinct clss,course.name, course.data from student,course,course_grade where cou_sn=course.no and stu_sn=student.sn order by course.data desc; """, ) items6 = [row for row in db] template = jinja_env.get_template('manger2.html') return web.Response(text=template.render(items6=items6), content_type="text/html")
async def teacher(request): with db_block() as db: db.execute( ''' select teacher,name,data from course where no=%(no)s order by sn asc; ''', dict(no=username2)) items4 = [row for row in db] template = jinja_env.get_template('teacher.html') return web.Response(text=template.render(items4=items4), content_type="text/html")
async def class_pf(request): with db_block() as db: db.execute( """ select clss,student.name,course.name,grade,course.data from course,student,course_grade where cou_sn=course.no and stu_sn=student.sn order by course.data desc, student.sn asc """, ) items8 = [row for row in db] template = jinja_env.get_template('manger4.html') return web.Response(text=template.render(items8=items8), content_type="text/html")
async def student(request): with db_block() as db: db.execute( ''' select student.name,stu_sn,student.clss,course.name,course.data,grade from course_grade,student,course where stu_sn=student.sn and cou_sn=course.no and stu_sn=%(sn)s order by student.sn asc; ''', dict(sn=username)) items2 = [row for row in db] template = jinja_env.get_template('list.html') return web.Response(text=template.render(items2=items2), content_type="text/html")
async def check_plan(request): datas = await request.post() data = datas.get("semester") with db_block() as db: db.execute( """ select distinct clss,course.name, course.data from student,course,course_grade where cou_sn=course.no and stu_sn=student.sn and clss=%(clss)s order by course.data desc; """, dict(clss=data)) items7 = [row for row in db] template = jinja_env.get_template('manger3.html') return web.Response(text=template.render(items7=items7), content_type="text/html")
async def check_schedule(request): datas = await request.post() data = datas.get("semester") with db_block() as db: db.execute( """ select teacher,name,data from course where no=%(no)s and data=%(data)s order by course.sn asc; """, dict(no=username2, data=data)) items5 = [row for row in db] print(items5) template = jinja_env.get_template('teacher2.html') return web.Response(text=template.render(items5=items5), content_type="text/html")
async def check_semester(request): datas = await request.post() data = datas.get("semester") with db_block() as db: db.execute( """ select course.name,course.data,grade from course_grade,student,course where stu_sn=student.sn and cou_sn=course.no and stu_sn=%(sn)s and data=%(data)s order by course.sn asc; """, dict(sn=username, data=data)) items3 = [row for row in db] template = jinja_env.get_template('list2.html') return web.Response(text=template.render(items3=items3), content_type="text/html")
from os import path from aiohttp import web import jinja2 from pathlib import Path from dbconn import db_block from cryptography.fernet import InvalidToken from cryptography.fernet import Fernet secret_key = Fernet.generate_key() fernet = Fernet(secret_key) home_path = str(Path(__file__).parent) jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader(home_path)) with db_block() as db: db.execute(''' select no,sn from student order by no asc; ''') items = tuple([tuple(row) for row in db]) passwords = dict((y, x) for x, y in items) ######密码是序号 with db_block() as db: db.execute(''' select sn,no from course order by sn asc; ''') items = tuple([tuple(row) for row in db]) passwords2 = dict((y, x) for x, y in items) passwords3 = {"tom": "666"} ###学生 async def login_form_page(request):