#创建ath_list页面,这里有运动员的列表 import athletemodel import YATE import glob #可以获取文件列表 data_files = glob.glob("data/*.txt")#获取data 目录下的所有txt athletes = athletemodel.put_to_store(data_files)#将txt的内容存入 pickle,并返回字典 print(YATE.start_response()) print(YATE.include_header('List of Athletes')) #web的头 print(YATE.start_form('generate_timing_data.py'))#需要进一步处理表单的表单,即submit后处理请求的页面 print(YATE.para('Select an Athlete!')) for each_ath in athletes: print(YATE.radio_button('which_athlete',athletes[each_ath].name))#which_athlete是radiobutton的name属性, print(YATE.end_form('Select')) print(YATE.include_footer({'Home':'/index.html'}))
import cgi import cgitb #开启浏览器追踪 cig 信息 import athletemodel import YATE cgitb.enable() #cgitb #开启浏览器追踪 cig 信息 #athletes = athletemodel.get_from_store()#从pickle获取信息 form_data = cgi.FieldStorage() #获取请求的form的内容 #athlete_name = form_data['which_athlete'].value#从内容中得到请求控件name 为:which_athlete的值 athlete_id = form_data['which_athlete'].value # radio 在 yate.py 里重写了 athletes = athletemodel.get_athlete_from_id(athlete_id) print(YATE.start_response()) print(YATE.include_header("NUAC's Timing Data")) print( YATE.header('Althlete:' + athletes['Name'] + ' ,DOB: ' + athletes['DOB'] + '.')) print(YATE.para('The top times for this athlete are:')) print(YATE.u_list(athletes['top3'])) print( YATE.para("The entire set of timing data is:" + str(athletes['data']) + " (duplicates removed).")) print( YATE.include_footer({ 'Home': '/index.html', 'Select another athlete': 'generate_list.py' }))
import cgi import cgitb #开启浏览器追踪 cig 信息 import athletemodel import YATE cgitb.enable()#cgitb #开启浏览器追踪 cig 信息 athletes = athletemodel.get_from_store()#从pickle获取信息 form_data = cgi.FieldStorage()#获取请求的form的内容 athlete_name = form_data['which_athlete'].value#从内容中得到请求控件name 为:which_athlete的值 print(YATE.start_response()) print(YATE.include_header('Timing Data')) print(YATE.header('Althlete:'+athlete_name+' ,DOB: ' +athletes[athlete_name].dob+'.')) print(YATE.para('The top times for this athlete are:')) print(YATE.u_list(athletes[athlete_name].top3))#这里需要在top3方法那加入@property将类方法表现得像个类属性 print(YATE.include_footer({'Home':'/index.html', 'Select another athlete':'generate_list.py'}))
#创建ath_list页面,这里有运动员的列表 import athletemodel import YATE import glob #可以获取文件列表 data_files = glob.glob("data/*.txt") #获取data 目录下的所有txt athletes = athletemodel.put_to_store(data_files) #将txt的内容存入 pickle,并返回字典 print(YATE.start_response()) print(YATE.include_header('List of Athletes')) #web的头 print( YATE.start_form('generate_timing_data.py')) #需要进一步处理表单的表单,即submit后处理请求的页面 print(YATE.para('Select an Athlete!')) for each_ath in athletes: print(YATE.radio_button( 'which_athlete', athletes[each_ath].name)) #which_athlete是radiobutton的name属性, print(YATE.end_form('Select')) print(YATE.include_footer({'Home': '/index.html'}))
import cgi import cgitb #开启浏览器追踪 cig 信息 import athletemodel import YATE cgitb.enable()#cgitb #开启浏览器追踪 cig 信息 #athletes = athletemodel.get_from_store()#从pickle获取信息 form_data = cgi.FieldStorage()#获取请求的form的内容 #athlete_name = form_data['which_athlete'].value#从内容中得到请求控件name 为:which_athlete的值 athlete_id = form_data['which_athlete'].value # radio 在 yate.py 里重写了 athletes = athletemodel.get_athlete_from_id(athlete_id) print(YATE.start_response()) print(YATE.include_header("NUAC's Timing Data")) print(YATE.header('Althlete:'+athletes['Name']+' ,DOB: ' +athletes['DOB']+'.')) print(YATE.para('The top times for this athlete are:')) print(YATE.u_list(athletes['top3'])) print(YATE.para("The entire set of timing data is:"+str(athletes['data'])+ " (duplicates removed).")) print(YATE.include_footer({'Home':'/index.html', 'Select another athlete':'generate_list.py'}))
import cgi import cgitb #开启浏览器追踪 cig 信息 import athletemodel import YATE cgitb.enable() #cgitb #开启浏览器追踪 cig 信息 athletes = athletemodel.get_from_store() #从pickle获取信息 form_data = cgi.FieldStorage() #获取请求的form的内容 athlete_name = form_data[ 'which_athlete'].value #从内容中得到请求控件name 为:which_athlete的值 print(YATE.start_response()) print(YATE.include_header('Timing Data')) print( YATE.header('Althlete:' + athlete_name + ' ,DOB: ' + athletes[athlete_name].dob + '.')) print(YATE.para('The top times for this athlete are:')) print(YATE.u_list( athletes[athlete_name].top3)) #这里需要在top3方法那加入@property将类方法表现得像个类属性 print( YATE.include_footer({ 'Home': '/index.html', 'Select another athlete': 'generate_list.py' }))