def generate_list(): if request.method == 'POST': if request.values['send'] == 'Submit': if 'Which_athlete' in request.values: return redirect( url_for('generate_timing_data', name=request.values.get('Which_athlete'))) else: return render_template( 'generate_list.html', alert='請選擇人物啦', names=athletemodel.get_names_from_store()) elif request.values['send'] == 'creat_athlete': dob = request.values['Dob'] name = request.values['Name'] athletemodel.add_athlete(name, dob) return render_template('generate_list.html', names=athletemodel.get_names_from_store())
def generate_names(): athletes = athletemodel.get_names_from_store() json_athletes = json.dumps(sorted(athletes)) print(yate.start_response('application/json')) print(json_athletes)
import json import athletemodel import yate names = athletemodel.get_names_from_store() print(yate.start_response('application/json')) print(json.dumps(sorted(names)))
#! /usr/bin/env python # Date:2020/5/12 # Author:Lingchen # Mark: 将数据作为一个Json数据流返回给Web请求者 import json import athletemodel import yate names = athletemodel.get_names_from_store() print(yate.start_response('application/json')) print(json.dumps(sorted(names)))
import glob #from athletemodel import put_to_store, get_names_from_store import athletemodel #the_files = ["sarah2.txt", "james2.txt", "mikey2.txt", "julie2.txt", ] the_files = glob.glob("../data/*2.txt") data = athletemodel.put_to_store(the_files) for one in data: print(data[one].name+":"+str(data[one])) print(athletemodel.get_names_from_store())
import athletemodel import yate import json print(yate.start_response("application/json")) print(json.dumps(athletemodel.get_names_from_store()))
import json from athletemodel import get_names_from_store import yate import cgitb cgitb.enable() names = get_names_from_store() print(yate.start_response('application/json')) print(json.dumps(sorted(names)))
#! /usr/local/bin/python3 import athletemodel import yate import json print(yate.start_response("application/json")) print(json.dumps(athletemodel.get_names_from_store()))