def get(self): uis = UserInfoStr()#this var holding the user info strings class from the lib file rp = ResultsPage()#this is making the result page usable in the main handler fp = FormPage()#this is making the form page usable in the main handler ui = UserInfo()#this var holding the user info class from the lib file if self.request.GET:#this is checking to see if info has been taken from the user ui.user_name = self.request.GET['user_name']#all of these vars are the information taken from the user. The information is then sent to the userInfo class ui.user_quest = self.request.GET['user_quest'] ui.user_color = self.request.GET['user_color'] ui.user_location = self.request.GET['user_location'] ui.sex = self.request.GET['sex'] ui.user_test = self.request.GET['user_test'] uis.add_user(ui)#this is taking the information from the UserInfo and sending it to the UserInfoStr rp.body = uis.user_output(uis.human_check())#this is taking the info from UserInfoStr and sending it to the results page all = rp.page_head + rp.body + rp.close all = all.format(**locals()) self.response.write(all)#this is posting the info to the screen else: self.response.write(fp.form_page_head + fp.page_form)#this is posting the form to the screen
def get(self): p = ResultsPage() fm = FavoriteMovies() #movie #year #director md1 = MovieData() md1.title = "The Princess Bride" md1.director = "Rob Reiner" md1.year = 1989 fm.add_movie(md1) md2 = MovieData() md2.title = "Dune" md2.director = "David Lynch" md2.year = 1986 fm.add_movie(md2) fm.calc_time() p.body = fm.compile_list() self.response.write(p.print_out())
def get(self): #to do list #enter in name #enter in grade 1 #enter in grade 2 #enter in grade 3 #enter in grade 4 gg = GetGrades() g = Grade() p = ResultsPage() f = FormPage() #page_head = p.head #page_form = p.form #page_close = p.close #page_result = p.result if self.request.GET: #stores info we got from form/information input g.name = self.request.GET['name'] #name g.age = self.request.GET['age'] #age g.g1 = self.request.GET['g1'] #grade1 g.g2 = self.request.GET['g2'] #grade2 g.g3 = self.request.GET['g3'] #grade3 g.g4 = self.request.GET['g4'] #grade4 avg = gg.calc_gpa(g) p.body = """<div class="form"><h1><p>Hello,<b> """ +g.name + """</b> Here is what you entered: <br> Grade 1:<b> """ +g.g1 + """</b><BR> Grade 2: <b>""" + g.g2 + """</b> <BR>Grade 3:<b> """ +g.g3 + """</b> <BR> Grade 4: <b>""" + g.g4 + """ <BR></b>We calculated that your GPA is<b> """+ str(avg) + """</b></b></p></div>""" self.response.write(p.print_out()) #p.body = gg.calc_gpa() + gg.get_grades() #below code is what prints out #self.response.write(p.print_out()) #self.response.write(page_head + page_result + '<h2> Hi ' + g.name + ",</h2><br> <h3>Here are the grades you entered:<BR> " + "<b>Age</b>" + g.age + "<b>Grade 1:</b> " +g.g1 + "<BR> <b>Grade 2:</b>" + g.g2 + "<BR><b> Grade 3:</b>" + g.g3 + "<BR><b>Grade 4:</b> " + g.g4 + page_close) else: self.response.write(f.print_out())
def get(self): #create an instance of our TeamData class for use in our main handler t = TeamData() #the below code happens if the user submits data via our field and prints the results page if self.request.GET: #Here (and the others below) we are setting our values equal to the input we received from the user via the form inputs p1 = PlayerData() p1.name = self.request.GET['p1_name'] #we use int() here (and below) to convert user input into numbers so we can use them in calculations. p1.kills = int(self.request.GET['p1_kills']) p1.assists = int(self.request.GET['p1_deaths']) p1.deaths = int(self.request.GET['p1_assists']) p1.heals = int(self.request.GET['p1_heals']) p1.abs = int(self.request.GET['p1_abs']) t.add_player( p1 ) #here (and the others below we are adding the player information gathered to our array of players in our TeamData class p2 = PlayerData() p2.name = self.request.GET['p2_name'] p2.kills = int(self.request.GET['p2_kills']) p2.assists = int(self.request.GET['p2_deaths']) p2.deaths = int(self.request.GET['p2_assists']) p2.heals = int(self.request.GET['p2_heals']) p2.abs = int(self.request.GET['p2_abs']) t.add_player(p2) p3 = PlayerData() p3.name = self.request.GET['p3_name'] p3.kills = int(self.request.GET['p3_kills']) p3.assists = int(self.request.GET['p3_deaths']) p3.deaths = int(self.request.GET['p3_assists']) p3.heals = int(self.request.GET['p3_heals']) p3.abs = int(self.request.GET['p3_abs']) t.add_player(p3) p4 = PlayerData() p4.name = self.request.GET['p4_name'] p4.kills = int(self.request.GET['p4_kills']) p4.assists = int(self.request.GET['p4_deaths']) p4.deaths = int(self.request.GET['p4_assists']) p4.heals = int(self.request.GET['p4_heals']) p4.abs = int(self.request.GET['p4_abs']) t.add_player(p4) p5 = PlayerData() p5.name = self.request.GET['p5_name'] p5.kills = int(self.request.GET['p5_kills']) p5.assists = int(self.request.GET['p5_deaths']) p5.deaths = int(self.request.GET['p5_assists']) p5.heals = int(self.request.GET['p5_heals']) p5.abs = int(self.request.GET['p5_abs']) t.add_player(p5) #if we gather inputs from the user, then p will equal the html from our ResultsPage class p = ResultsPage() #to compose our ResultsPage body we add in the results from out calculations with the TeamData class p.body = t.player_list() + t.calc_kills() + t.calc_deaths( ) + t.calc_abs() + t.calc_heals() #once everything is put together, we then write it to the page self.response.write(p.print_out()) else: #if we have not received data via form inputs, then our page body will be our form p = FormPage() #the below writes the form onto the page self.response.write(p.print_out())