python - self.request.GET[] with href HTML -


i need have self.request.get[] have correct code when user clicks, based on click in html.

below main.py:

import webapp2 data import fighter data import data pages import page pages import contentpage   class mainhandler(webapp2.requesthandler):     def get(self):          f = fighter()         d = data()         p = page()         c = contentpage()          if self.request.get[1]:             self.response.write(c.results(d.fighter_data[0].name, d.fighter_data[0].rank, d.fighter_data[0].age, d.fighter_data[0].hometown, d.fighter_data[0].fights_out_of, d.fighter_data[0].height, d.fighter_data[0].weight, d.fighter_data[0].reach, d.fighter_data[0].wins, d.fighter_data[0].loses, d.fighter_data[0].bio))         else:             self.response.write(p.page)  app = webapp2.wsgiapplication([ ('/', mainhandler) ], debug=true) 

where if self.request.get[1]: needs work if ?fighter=1 clicked

pages.py below:

class page(object):     def __init__(self):         self.page = '''         <!doctype html>         <html>         <head>         <meta charset="utf-8">         <title>untitled document</title>         </head>          <body>          <a href="?fighter=1">flweight</a>         <a href="?fighter=2">bantamweight</a>         <a href="?fighter=3">featherweight</a>         <a href="?fighter=4">lightweight</a>         <a href="?fighter=5">welterweight</a>          </body>         </html>'''      def content(self):         content_page = self.page  # set content page equal page         content_page = content_page.format(**locals())  # locals         return content_page  # return content_page   class contentpage(object):     def __init__(self):         self.data_page = '''         {name} {age} {rank} {hometown} {fights_out_of} {height} {weight} {reach} {wins} {loses} {bio}'''      def results(self, name, age, rank, hometown, fights_out_of, height, weight, reach, wins, loses, bio):  # stuff page         results_page = self.data_page  # set results page equal data page         results_page = results_page.format(**locals())  # locals         return results_page  # returns results_page 

i appreciate help. thanks.

i have solved own question. it's:

        if self.request.get:             if self.request.get['fighter']:                 self.response.write(c.results(d.fighter_data[0].name, d.fighter_data[0].rank, d.fighter_data[0].age, d.fighter_data[0].hometown, d.fighter_data[0].fights_out_of, d.fighter_data[0].height, d.fighter_data[0].weight, d.fighter_data[0].reach, d.fighter_data[0].wins, d.fighter_data[0].loses, d.fighter_data[0].bio))             elif self.request.get['fighter'] == 2:                 self.response.write(c.results(d.fighter_data[1].name, d.fighter_data[1].rank, d.fighter_data[1].age, d.fighter_data[1].hometown, d.fighter_data[1].fights_out_of, d.fighter_data[1].height, d.fighter_data[1].weight, d.fighter_data[1].reach, d.fighter_data[1].wins, d.fighter_data[1].loses, d.fighter_data[1].bio))             elif self.request.get['fighter'] == 3:                 self.response.write(c.results(f.name, f.age, f.rank, f.hometown, f.fights_out_of, f.height, f.weight, f.reach, f.wins, f.loses, f.bio))             elif self.request.get['fighter'] == 4:                 self.response.write(c.results(f.name, f.age, f.rank, f.hometown, f.fights_out_of, f.height, f.weight, f.reach, f.wins, f.loses, f.bio))             elif self.request.get['fighter'] == 5:                 self.response.write(c.results(f.name, f.age, f.rank, f.hometown, f.fights_out_of, f.height, f.weight, f.reach, f.wins, f.loses, f.bio))         else:             self.response.write(p.page) 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -