diff --git a/24-P321-from_pickle_toSQLite/athletemodel.py b/24-P321-from_pickle_toSQLite/athletemodel.py index 8505697..d7de0e9 100644 --- a/24-P321-from_pickle_toSQLite/athletemodel.py +++ b/24-P321-from_pickle_toSQLite/athletemodel.py @@ -1,4 +1,4 @@ -#import pickle +########使用sqlite 创建新的模型 import sqlite3 from athletelist import AthleteList @@ -22,6 +22,7 @@ def get_athlete_from_id(athlete_id): (name, dob) = results.fetchone() results = cursor.execute("""SELECT value FROM timing_data WHERE athlete_id=?""", (athlete_id,)) + #从查询结果中得到数据,转化为一个字典 response = { 'Name': name, 'DOB': dob, 'data': data, @@ -29,8 +30,24 @@ def get_athlete_from_id(athlete_id): connection.close() return(response) +def get_namesID_from_store(): + connection = sqlite3.connect(db_name) + cursor = connection.cursor() + results = cursor.execute("""SELECT name,id FROM athletes""") + response = results.fetchall() + connection.close() + return(response) + +"""测试代码 +data = get_namesID_from_store() +print (data) +print (data[0][0]) +""" +##########sqlite模型 +#####旧的模型使用的是pickle +import pickle def get_coach_data(filename): #从文件中获取数据 try: diff --git a/24-P321-from_pickle_toSQLite/athletes.pickle b/24-P321-from_pickle_toSQLite/athletes.pickle index 5298c91..cd25e22 100644 Binary files a/24-P321-from_pickle_toSQLite/athletes.pickle and b/24-P321-from_pickle_toSQLite/athletes.pickle differ diff --git a/24-P321-from_pickle_toSQLite/coachdata.sqlite b/24-P321-from_pickle_toSQLite/coachdata.sqlite index a816301..9de3eb4 100644 Binary files a/24-P321-from_pickle_toSQLite/coachdata.sqlite and b/24-P321-from_pickle_toSQLite/coachdata.sqlite differ diff --git a/24-P321-from_pickle_toSQLite/from_pickle_toSQLite.py b/24-P321-from_pickle_toSQLite/from_pickle_toSQLite.py index d981102..97c3e29 100644 --- a/24-P321-from_pickle_toSQLite/from_pickle_toSQLite.py +++ b/24-P321-from_pickle_toSQLite/from_pickle_toSQLite.py @@ -19,7 +19,7 @@ #插入time_data 表 cursor.execute("SELECT id FROM athletes WHERE name=? and dob=?",(name,dob)) - the_current_id = cursor.fetchone()[0] + the_current_id = cursor.fetchone()[0]# fetchone 返回一个列表 for each_time in athletes[each_ath].clean_data: cursor.execute("INSERT INTO timing_data(athlete_id,value) VALUES(?,?)",(the_current_id,each_time)) diff --git a/24-P337-sqlite-neweb/ad-coachapp.py b/24-P337-sqlite-neweb/ad-coachapp.py new file mode 100644 index 0000000..d6fde0d --- /dev/null +++ b/24-P337-sqlite-neweb/ad-coachapp.py @@ -0,0 +1,80 @@ +import android +import json +import time +import sys + +from urllib.parse import urlencode +from urllib.request import urlopen + +#app 的所有消息 +hello_msg = "Welcome to Coach Kelly's Timing App" +list_title = 'Here is your list of athletes' +quit_msg = "Quitting Coach Kelly's App." +web_server = 'http://192.168.1.180:8082' +get_name_cgi = '/cgi-bin/generate_name.py' + +get_data_cgi = '/cgi-bin/generate_data.py' + + +#send to server 取一个web地址(url) 和一些可选数据(post_data) +#它向web 服务器发送一份web请求(urlopen) +#web响应返回给调用者(return) +def send_to_server(url, post_data=None): + if post_data: + page = urlopen(url,urlencode(post_data).encode('utf-8')) + else: + page = urlopen(url) + return(page.read().decode('utf-8')) + +app = android.Android() + +def status_update(msg, how_long = 2 ): + app.makeToast(msg) + time.sleep(how_long) + +status_update(hello_msg) + + +#athlete_names = sorted (json.loads(send_to_server(web_server + get_name_cgi))) +athletes = sorted (json.loads(send_to_server(web_server + get_name_cgi))) +athlete_names = [ath[0] for ath in athletes] + +app.dialogCreateAlert(list_title) +app.dialogSetSingleChoiceItems(athlete_names) +app.dialogSetPositiveButtonText('Select') +app.dialogSetNegativeButtonText('Quit') +app.dialogShow() +resp = app.dialogGetResponse().result + + +if resp['which'] in ('positive'): + selected_athlete = app.dialogGetSelectedItems().result[0] + #which_athlete = athlete_names[selected_athlete] + which_athlete = athletes[selected_athlete][1]#确定选手关联的id + #print("####"+str(which_athlete)+"###", file=sys.stderr) + athlete = json.loads(send_to_server(web_server + get_data_cgi,{'which_athlete': which_athlete})) + athlete_title = athlete['Name'] + '(' + athlete['DOB'] + '), top 3 times:' + app.dialogCreateAlert(athlete_title) + #app.dialogSetItems(athlete['Top3']) + app.dialogSetItems(athlete['top3']) + app.dialogSetPositiveButtonText('OK') + + app.dialogSetNegativeButtonText('Add Time') + + app.dialogShow() + resp = app.dialogGetResponse().result + + if resp['which'] in ('positive'): + pass + elif resp['which'] in ('negative'): + timing_title = 'Enter new time' + timing_msg = 'Provide a new timing value '+ athlete['Name']+': ' + add_time_cgi = '/cgi-bin/add_timing_data.py' + + resp = app.dialogGetInput(timing_title,timing_msg).result + + if resp is not None: + new_time = resp + send_to_server(web_server+add_time_cgi,{'Time':new_time,'Athlete':which_athlete}) + +status_update(quit_msg) diff --git a/24-P337-sqlite-neweb/webapp/athletes.pickle b/24-P337-sqlite-neweb/webapp/athletes.pickle new file mode 100644 index 0000000..011973a Binary files /dev/null and b/24-P337-sqlite-neweb/webapp/athletes.pickle differ diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/23-p319-createsimpledb.py b/24-P337-sqlite-neweb/webapp/cgi-bin/23-p319-createsimpledb.py new file mode 100644 index 0000000..bfdc852 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/23-p319-createsimpledb.py @@ -0,0 +1,17 @@ +import sqlite3 + +connection =sqlite3.connect('coachdata.sqlite') + +cursor = connection.cursor() + +cursor.execute(""" CREATE TABLE athletes ( + id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL, + name TEXT NOT NULL, + dob DATE NOT NULL)""") +cursor.execute(""" CREATE TABLE timing_data( + athlete_id INTEGER NOT NULL, + value TEXT NOT NULL, + FOREIGN KEY (athlete_id) REFERENCES atheletes)""") +connection.commit() +connection.close() + diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/YATE.py b/24-P337-sqlite-neweb/webapp/cgi-bin/YATE.py new file mode 100644 index 0000000..0e4d044 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/YATE.py @@ -0,0 +1,86 @@ +from string import Template +#Template 模块的相关内容,简单的字符串替换模板 + +def start_response(resp='text/html'): + return ('Content-type: '+ resp +'\n\n') +#一个可选的字符串作为参数,用它来创建cgi 的 content-type: 行,缺省为 text/html + +def include_header(the_title): + with open('templates/header.html') as headf: + head_text = headf.read() + header = Template(head_text) + return (header.substitute(title=the_title)) +#将从header.html中读入的文件,替换所提供的标题 + +def include_footer(the_links): + with open('templates/footer.html') as footf: + foot_text = footf.read() + link_string = '' + for key in the_links: + link_string += ''+key+'    ' + footer = Template(foot_text) + return(footer.substitute(links=link_string)) +#使用一个字符串作为参数,来创建一个 html 页面的尾部,页面本身存于 footer.html 中, +#参数用于动态创建一组动态 html 链接标记,从使用来看,参数应该是一个字典 + +def start_form(the_url,form_type='POST'): + return('
') +#返回表单最前面的HTML, 允许调用者制定URL,(表单数据将发送到这个URL) +#还可以指定所要使用的方法 + + +def end_form(submit_msg="Submit"): + return('

') +#返回表单末尾的html标记,同事允许定制submit按钮的文本 + +def radio_button(rb_name,rb_value): + return(''+ rb_value+'
') +#给定一个单选按钮的名和值,创建一个html 单选按钮,两个参数都是必须的 + + +def raido_button_id(rb_name,rb_value,rb_id): + return(''+rb_value+'
') +#重新创建单选按钮,为她提供和文本不同的值 + +def u_list(items): + u_string = '' + return(u_string) +# 给定一个项列表,将其转化为一个html 列表,每次迭代会像ul增加一个li元素 + +def header(header_text,header_level=2): + return (''+header_text+ + '') +#返回一个 html 标题标记,默认为2级标题 + +def para(para_text): + return('

'+para_text+'

') +#段落标记一个文本段 + + + +def create_inputs(inputs_list): + html_inputs = '' + for each_input in inputs_list: + html_inputs = html_inputs + '' + return (html_inputs) + +def do_form(name, the_inputs,method='POST',text='Submit'): + with open ('templates/form.html') as formf: + form_text=formf.read() + inputs = create_inputs(the_inputs) + form = Template(form_text) + + return(form.substitute(cgi_name=name,http_method = method,list_of_inputs=inputs,submit_text=text)) + + + + + + + diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/add_timing_data.py b/24-P337-sqlite-neweb/webapp/cgi-bin/add_timing_data.py new file mode 100644 index 0000000..8900ed3 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/add_timing_data.py @@ -0,0 +1,34 @@ +import cgi +import os +import time +import sys +import YATE +import sqlite3 + +print (YATE.start_response('text/plain')) +addr = os.environ['REMOTE_ADDR'] +host = os.environ['REMOTE_HOST'] +method = os.environ['REQUEST_METHOD'] +cur_time = time.asctime(time.localtime()) + +print (host+", "+addr+", "+cur_time+": "+method, file=sys.stderr) + +form_data = cgi.FieldStorage() +the_id = form_data['Athlete'].value +the_time = form_data['Time'].value + +connection = sqlite3.connect('coachdata.sqlite') +cursor = connection.cursor() +cursor.execute("INSERT INTO timing_data (athlete_id,value) VALUES (?,?)", + (the_id, the_time)) +""" +for each_form_item in form.keys(): + print (each_form_item + '->' + form[each_form_item].value, + end=' ', file=sys.stderr) +print (file = sys.stderr) #在标准错误输出上换行 +""" +connection.commit() +connection.close() +print ('OK.') + + diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/athletelist.py b/24-P337-sqlite-neweb/webapp/cgi-bin/athletelist.py new file mode 100644 index 0000000..6b8cb84 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/athletelist.py @@ -0,0 +1,34 @@ +class AthleteList(list): #新的AthleteList 类,继承了原有的list类,包含了原list的所有方法 append,extend + def __init__(self,a_name,a_dob=None,a_times=[]): + list.__init__([]) + self.name = a_name + self.dob = a_dob + self.extend(a_times) + @property + def top3(self): + return(sorted(set([sanitize(t) for t in self]))[0:3]) + @property + def clean_data(self): + return(sorted(set([sanitize(t) for t in self]))) + + +def sanitize(time_string): #序列化得到的无规则数据,将其格式化为 mins.secs 的格式 + if '-' in time_string: + splitter = '-' + elif ':' in time_string: + splitter = ':' + else: + return(time_string) + (mins,secs)=time_string.split(splitter) + return(mins+'.'+secs) + +def load_from_file(filename): #读取文件的一行(这个文件只有一行,多行咋办) + try: + with open (filename) as f: + data = f.readline() + templ = data.strip().split(',') + return (Athlete(templ.pop(0),templ.pop(0),templ))#返回一个Athlete对象,这里已经pop了两次,所以返回值里只有times了 + except IOError as err: + print('File Error: '+str(err)) + return (None) + diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/athletemodel.py b/24-P337-sqlite-neweb/webapp/cgi-bin/athletemodel.py new file mode 100644 index 0000000..3d4a9a7 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/athletemodel.py @@ -0,0 +1,103 @@ +########使用sqlite 创建新的模型 +import sqlite3 + +from athletelist import AthleteList + +db_name = 'coachdata.sqlite' + + +def get_names_from_store(): + connection = sqlites3.connect(db_name) + cursor = connection.cursor() + results = cursor.execute("""SELECT name FROM athletes""") + response = [row[0] for row in results.fetchall()] + connection.close() + return (response) + +def get_athlete_from_id(athlete_id): + connection = sqlite3.connect(db_name) + cursor = connection.cursor() + results = cursor.execute("""SELECT name, dob FROM athletes WHERE id=?""", + (athlete_id,)) + (name, dob) = results.fetchone() + results = cursor.execute("""SELECT value FROM timing_data WHERE athlete_id=?""", + (athlete_id,)) + data = [row[0] for row in results.fetchall()] + + #从查询结果中得到数据,转化为一个字典 + response = { 'Name': name, + 'DOB': dob, + 'data': data, + 'top3': data[0:3]} + connection.close() + return(response) + +def get_namesID_from_store(): + connection = sqlite3.connect(db_name) + cursor = connection.cursor() + results = cursor.execute("""SELECT name,id FROM athletes""") + response = results.fetchall() + connection.close() + return(response) + +"""测试代码 +data = get_namesID_from_store() +print (data) +print (data[0][0]) +print (data[0][1]) +""" + + +##########sqlite模型 + +#####旧的模型使用的是pickle +import pickle +def get_coach_data(filename): #从文件中获取数据 + + try: + with open (filename) as f: + data = f.readline() + templ = data.strip().split(',') + return (AthleteList(templ.pop(0),templ.pop(0),templ)) + except IOError as ioerr: + print ('File Error: ' + str(ioerr)) + return (None) + + +def put_to_store(file_list): + + all_athletes = {} + for each_f in file_list: + ath = get_coach_data(each_f) #这里ath 返回的 athletelist 的对象(athletelist 是一个list) + #all_athletes['Name'] = ath.name + #all_athletes['DOB'] = ath.dob + #all_athletes['Times']= ath + all_athletes[ath.name] = ath #将ath name 作为键,将ath作为值 + + try: + with open ('athletes.pickle','wb') as ath_f: + pickle.dump (all_athletes,ath_f) + except IOError as ioerr: + print('File Error(put_to_store): '+str(ioerr)) + return (all_athletes) + +def get_from_store(): + + all_athletes = {} + try: + with open ('athletes.pickle','rb') as ath_f: + all_athletes = pickle.load(ath_f) + except IOError as ioerr: + print('File Error(get_from_store): '+str(ioerr)) + + return (all_athletes) + +""" +测试代码 +files = ['sarah2.txt','james2.txt','mikey2.txt','julie2.txt'] +data = put_to_store(files)#data 是一个字典 +print(data) +for each_ath in data: + #print(data[each_ath].name + ' ' +data[each_ath].dob ) + print(data[each_ath].name) +""" diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/athletes.pickle b/24-P337-sqlite-neweb/webapp/cgi-bin/athletes.pickle new file mode 100644 index 0000000..cd25e22 Binary files /dev/null and b/24-P337-sqlite-neweb/webapp/cgi-bin/athletes.pickle differ diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/from_pickle_toSQLite.py b/24-P337-sqlite-neweb/webapp/cgi-bin/from_pickle_toSQLite.py new file mode 100644 index 0000000..97c3e29 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/from_pickle_toSQLite.py @@ -0,0 +1,26 @@ +import sqlite3 + +connection = sqlite3.connect('coachdata.sqlite') + +cursor = connection.cursor() + +import glob +import athletemodel + +data_files = glob.glob("data/*.txt") +athletes = athletemodel.put_to_store(data_files) +for each_ath in athletes: + #插入 athletes 表 + name = athletes[each_ath].name + dob = athletes[each_ath].dob + + cursor.execute("INSERT INTO athletes (name,dob) VALUES (?,?)",(name,dob)) + connection.commit() + + #插入time_data 表 + cursor.execute("SELECT id FROM athletes WHERE name=? and dob=?",(name,dob)) + the_current_id = cursor.fetchone()[0]# fetchone 返回一个列表 + for each_time in athletes[each_ath].clean_data: + cursor.execute("INSERT INTO timing_data(athlete_id,value) VALUES(?,?)",(the_current_id,each_time)) + +connection.close() diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/generate_data.py b/24-P337-sqlite-neweb/webapp/cgi-bin/generate_data.py new file mode 100644 index 0000000..edc0ecc --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/generate_data.py @@ -0,0 +1,14 @@ +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)) diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/generate_list.py b/24-P337-sqlite-neweb/webapp/cgi-bin/generate_list.py new file mode 100644 index 0000000..e33c415 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/generate_list.py @@ -0,0 +1,25 @@ +#创建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,并返回字典 + +import cgitb #开启浏览器追踪 cig 信息 + +cgitb.enable()#cgitb #开启浏览器追踪 cig 信息 + +athletes = athletemodel.get_namesID_from_store() + +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.raido_button_id('which_athlete',each_ath[0],each_ath[1]))#which_athlete是radiobutton的name属性, +print(YATE.end_form('Select')) +print(YATE.include_footer({'Home':'/index.html'})) + + diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/generate_name.py b/24-P337-sqlite-neweb/webapp/cgi-bin/generate_name.py new file mode 100644 index 0000000..8ed91e8 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/generate_name.py @@ -0,0 +1,9 @@ +import athletemodel +import YATE +import json +import cgitb #开启浏览器追踪 cig 信息 + +cgitb.enable()#cgitb #开启浏览器追踪 cig 信息 +ath_names = athletemodel.get_namesID_from_store() +print(YATE.start_response('application/json')) +print(json.dumps(sorted(ath_names))) diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/generate_timing_data.py b/24-P337-sqlite-neweb/webapp/cgi-bin/generate_timing_data.py new file mode 100644 index 0000000..ed12279 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/generate_timing_data.py @@ -0,0 +1,26 @@ +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'})) diff --git a/24-P337-sqlite-neweb/webapp/cgi-bin/test_form.py b/24-P337-sqlite-neweb/webapp/cgi-bin/test_form.py new file mode 100644 index 0000000..3590bd6 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/cgi-bin/test_form.py @@ -0,0 +1,6 @@ +import YATE +import cgitb + +cgitb.enable() +print (YATE.start_response('text/html')) +print (YATE.do_form('add_timing_data.py',['TimeValue'],text='Send')) diff --git a/24-P337-sqlite-neweb/webapp/coach.css b/24-P337-sqlite-neweb/webapp/coach.css new file mode 100644 index 0000000..188aac6 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/coach.css @@ -0,0 +1,73 @@ +body { + font-family: Verdana, Geneva, Arial, sans-serif; + font-size: small; +} +a { + text-decoration: none; + font-weight: 600; + color: #cc6600; +} +a:hover { + text-decoration: underline; +} +a img { + border: 0; +} +h1, h2 { + font-weight: normal; + color: #cc6600; + border-bottom: thin dotted #888888; +} +h1 { + font-size: 170%; +} +h2 { + font-size: 130%; +} +blockquote { + font-style: italic; +} + +table { + margin-left: 20px; + margin-right: 20px; + border: thin solid black; + caption-side: bottom; + border-collapse: collapse; +} + +td, th { + border: thin dotted gray; + padding: 5px; +} + +th { + background-color: #cc6600; +} + +caption { + font-style: italic; + padding-top: 8px; +} + +.center { + text-align: center; +} + +.right { + text-align: right; +} + +.cellcolor { + background-color: #fcba7a; +} + +table table th { + background-color: white; +} + +li { + list-style-image: url(images/backpack.gif); + padding-top: 5px; + margin-left: 10px; +} diff --git a/24-P337-sqlite-neweb/webapp/data/james2.txt b/24-P337-sqlite-neweb/webapp/data/james2.txt new file mode 100644 index 0000000..daa6cf5 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/data/james2.txt @@ -0,0 +1 @@ +James Lee,2002-3-14,2-34,3:21,2.34,2.45,3.01,2:01,2:01,3:10,2-22,2-01,2.01,2:16 diff --git a/24-P337-sqlite-neweb/webapp/data/julie2.txt b/24-P337-sqlite-neweb/webapp/data/julie2.txt new file mode 100644 index 0000000..8a0be66 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/data/julie2.txt @@ -0,0 +1 @@ +Julie Jones,2002-8-17,2.59,2.11,2:11,2:23,3-10,2-23,3:10,3.21,3-21,3.01,3.02,2:59 diff --git a/24-P337-sqlite-neweb/webapp/data/mikey2.txt b/24-P337-sqlite-neweb/webapp/data/mikey2.txt new file mode 100644 index 0000000..a57f8ac --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/data/mikey2.txt @@ -0,0 +1 @@ +Mikey McManus,2002-2-24,2:22,3.01,3:01,3.02,3:02,3.02,3:22,2.49,2:38,2:40,2.22,2-31 diff --git a/24-P337-sqlite-neweb/webapp/data/sarah2.txt b/24-P337-sqlite-neweb/webapp/data/sarah2.txt new file mode 100644 index 0000000..d2ee229 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/data/sarah2.txt @@ -0,0 +1 @@ +Sarah Sweeney,2002-6-17,2:58,2.58,2:39,2-25,2-55,2:54,2.18,2:55,2:55,2:22,2-21,2.22 diff --git a/24-P337-sqlite-neweb/webapp/images/coach-head.jpg b/24-P337-sqlite-neweb/webapp/images/coach-head.jpg new file mode 100644 index 0000000..9fed13d Binary files /dev/null and b/24-P337-sqlite-neweb/webapp/images/coach-head.jpg differ diff --git a/24-P337-sqlite-neweb/webapp/index.html b/24-P337-sqlite-neweb/webapp/index.html new file mode 100644 index 0000000..a679438 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/index.html @@ -0,0 +1,16 @@ + + +Welcome to Coach Kelly's Website + + + + +

Welcome to Coach Kelly's Website.

+

+For now, all that you'll find here is my athlete's timing data. Enjoy! +

+

+See you on the track! +

+ + diff --git a/24-P337-sqlite-neweb/webapp/simplehttpd.py b/24-P337-sqlite-neweb/webapp/simplehttpd.py new file mode 100644 index 0000000..755bf00 --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/simplehttpd.py @@ -0,0 +1,6 @@ +from http.server import HTTPServer,CGIHTTPRequestHandler +#配置一个简单的httpserver +port = 8082 +httpd = HTTPServer(('',port),CGIHTTPRequestHandler) +print('Starting simple_httpd on port:' +str(httpd.server_port)) +httpd.serve_forever() diff --git a/24-P337-sqlite-neweb/webapp/templates/footer.html b/24-P337-sqlite-neweb/webapp/templates/footer.html new file mode 100644 index 0000000..033103e --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/templates/footer.html @@ -0,0 +1,5 @@ +

+$links +

+ + diff --git a/24-P337-sqlite-neweb/webapp/templates/form.html b/24-P337-sqlite-neweb/webapp/templates/form.html new file mode 100644 index 0000000..1dda84a --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/templates/form.html @@ -0,0 +1,3 @@ +
+Enter a timing value:$list_of_inputs
+
\ No newline at end of file diff --git a/24-P337-sqlite-neweb/webapp/templates/header.html b/24-P337-sqlite-neweb/webapp/templates/header.html new file mode 100644 index 0000000..cecf69d --- /dev/null +++ b/24-P337-sqlite-neweb/webapp/templates/header.html @@ -0,0 +1,7 @@ + + +$title + + + +

$title