import webapp2 # from main_pages import MainPage class MainHandler(webapp2.RequestHandler): def get(self): p = Page() if self.request.GET: thing1 = self.request.GET['thing1'] thing2 = self.request.GET['thing2'] self.response.write(p.print_final()) print thing1 + thing2 else: self.response.write(p.print_this()) class Page(object): def __init__(self): self.stuff = """ <!DOCTYPE HTML> <html> <head> <title>Give Us Yo INFO</title> <link href="css/main.css" rel="stylesheet"> </head> <body> <header> <h1>Some Header</h1> </header> <div class="main-form"> <form method="GET" action=""> <h2>Your Juice Sheet</h2> <label>Name: </label> <input type="text" name="thing1"> <label>Email: </label> <input type="text" name="thing2"> <input type="submit" value="Submit"/> </form> </div> </body> </html> """ self.final = """ <!DOCTYPE HTML> <html> <head> <title>Give us YO INFO</title> <link href="css/main.css" rel="stylesheet"> </head> <body> <header> <h1>Some Header</h1> </header> <div class="result"> <h2>Thing1</h2> <div class= "thing1-input"> <h3>Name</h3> <p></p> </div> <div class= "thing2-input"> <h3>Thing2</h3> <p></p> </div> </div> </body> </html> """ def print_this(self): page_content = self.stuff page_content = page_content.format(**locals()) return page_content def print_final(self): final_page_content = self.final final_page_content = final_page_content.format(**locals()) return final_page_content app = webapp2.WSGIApplication([ ('/', MainHandler) ], debug=True)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question