def generate_timing_data():
    athlete_name = request.values.get('name')
    athlete_id = athletemodel.get_ID_from_name(athlete_name)
    athlete = athletemodel.get_athlete_from_id(athlete_id)
    return render_template('generate_timing_data.html',
                           name=athlete['Name'],
                           dob=athlete['DOB'],
                           top3=athlete['top3'],
                           data=athlete['data'])
#!/usr/local/bin/python3

import cgi
import json
import athletemodel
import htmlutil

form_data = cgi.FieldStorage()
athlete_id = form_data['which_athlete'].value
athlete = athletemodel.get_athlete_from_id(athlete_id)
print(htmlutil.start_response('application/json'))
print(json.dumps(athlete))
Example #3
0
#! /usr/local/bin/python3

import cgi
import athletemodel
import yate

form_data = cgi.FieldStorage()
athlete_id = form_data['which_athlete'].value
athlete = athletemodel.get_athlete_from_id(athlete_id)

print((yate.start_response()))
print((yate.include_header("NUAC's Timing Data")))    
print((yate.header("Athlete: " + athlete['Name'] + ", DOB: " + athlete['DOB'] + ".")))
print((yate.para("The top times for this athlete are:")))
print((yate.u_list(athlete['top3'])))
print((yate.para("The entire set of timing data is: " + str(athlete['data']) +
                    " (duplicates removed).")))
print((yate.include_footer({"Home": "/index.html", "Select another athlete": "generate_list.py"})))

Example #4
0
# -*- coding: utf-8 -*-
#! /usr/local/bin/python3
__author__ = 'p.olifer'

import cgi, json, sys
import athletemodel, yate

#athletes = athletemodel.get_from_store()

form_data = cgi.FieldStorage()
athletes_name = form_data['which_athlete'].value
athlete = athletemodel.get_athlete_from_id(athletes_name)
print(yate.start_response('application/json'))
#print(json.dumps(athletes[athletes_name].as_dict))
print(json.dumps(athlete['Name'].as_dict))
import yate
import cgi
import athletemodel
import json
import cgitb
import sys

cgitb.enable()

form_data = cgi.FieldStorage()
athlete_name = form_data["which_athlete"].value
#print(athlete_name)
selected_athlete = athletemodel.get_athlete_from_id(athlete_name)
print(yate.start_response(resp="application/json"))
print(json.dumps(selected_athlete))
Example #6
0
__author__ = 'micheng'

import yate
import athletemodel

print(yate.start_response())
print(yate.include_header("The Champion For Now"))
print(yate.para("Here is the best player among all our athletes:"))

best_record = athletemodel.get_all_timing()[0]
best_timing = best_record[1]
champion = athletemodel.get_athlete_from_id(best_record[0])

print(yate.header(champion['Name'] + ', DOB: ' + champion['DOB'] + '.'))

print(
    yate.para('The entire set of timing data is: ' + str(champion['data']) +
              ' (duplicates removed).'))

print(yate.header("The best time is: <b>" + best_timing + "</b>"))
print(
    yate.include_footer({
        "Home": "/index.html",
        "Select another athlete": "generate_list.py"
    }))
Example #7
0
import cgi
import json
import athletemodel
import YATE
import sys

#athletes = athletemodel.get_from_store()
form_data = cgi.FieldStorage()
athlete_name = form_data['which_athlete'].value
athletes = athletemodel.get_athlete_from_id(athlete_name)
print (athletes, file=sys.stderr)
print(YATE.start_response('application/json'))
#print(json.dumps(athletes[athlete_name].as_dict))
print(json.dumps(athletes))
Example #8
0
__author__ = 'micheng'

import yate
import athletemodel

print(yate.start_response())
print(yate.include_header("The Champion For Now"))
print(yate.para("Here is the best player among all our athletes:"))


best_record = athletemodel.get_all_timing()[0]
best_timing = best_record[1]
champion = athletemodel.get_athlete_from_id(best_record[0])

print(yate.header(champion['Name'] + ', DOB: ' + champion['DOB'] +'.'))

print(yate.para('The entire set of timing data is: '+str(champion['data'])+' (duplicates removed).'))

print(yate.header("The best time is: <b>" + best_timing + "</b>"))
print(yate.include_footer({"Home": "/index.html", "Select another athlete": "generate_list.py"}))

#####此页面不展露在前端页面,只是dumps数据,以便前端页面loads数据#########

import athletemodel
import yate  #模板

import json

import cgitb
cgitb.enable()

#接收表单数据,获取value值,从数据库中查出对应的top3数据,并使用json.dumps存储成json格式,
# form_data=cgi.FieldStorage()  #返回一个字典
# athlete_id=form_data['which_athlete'].value #返回字典对应的健的值; 参照yate,在这里的value值==id值
# athletes=athletemodel.get_athlete_from_id(athlete_id)
athletes = athletemodel.get_athlete_from_id(
    '1')  #不知原因,上一行在浏览器无法取得选手athlete_id,这里指定一个id参数=‘1’
#根据方法 get_athlete_from_id(athlete_id)返回一个字典
# {
#     'Name':name,
#     'Bob':bob,
#     'data':data,
#     'top3':data[0:3]
# }
print(yate.start_response("application/json"))
print(json.dumps(athletes))