Join Club ShowMeDo to Learn Python!

This series is a part of Club ShowMeDo. Click to learn why you should join our club with a simple monthly subscription.

  • We teach Python and all the cool modules
  • Topics include beginner Python, GUIs, Web and Desktop Apps
  • Long, specially crafted video tutorials just for you
  • Club video tutorials extend our normal Free content
  • Save your time - we've done the research for you
  • Keep your skills up-to-date
  • Learn at your own pace, everything you need is shown to you
  • Over 12 hours of archived material are waiting for you in the club

Name: [008] Kyran Dale
Member: 107 months
Authored: 16 videos
Description: I'm one of the co-founders of Showmedo and an academic researcher by profession. My peripatetic path has taken me from a Philosophy degree via Artificial Intelligence and Evolutionary Robotics to a PhD in Neuroscience. I spent five years in a small room with a colony of reluctant bumble-bees, becomi ...

Handling Forms With webapp [ID:722] (5/5)

in series: A Gentle Introduction to the Google App Engine Python SDK

(Showmedo is undergoing major changes. To report any problems viewing the videos please email us and include browser and OS specifics. Cheers - Kyran.)

In this video we show a simple example of how the webapp framework deals with user input to generate a response to a posted web-form. Two handlers are used, the first to generate the form and the second to respond to the user input.

# Handling Forms With webapp
# s = cgi.escape( """& < >""" ) --> s = "&amp; &lt; &gt;"

import cgi
import wsgiref.handlers

from google.appengine.api import users
from google.appengine.ext import webapp

class MainPage(webapp.RequestHandler):
  def get(self):
    self.response.out.write("""
      <html>
        <body>
          <form action="/sign" method="post">
            <div><textarea name="content" rows="3" cols="60"></textarea></div>
            <div><input type="submit" value="Sign Guestbook"></div>
          </form>
        </body>
      </html>""")


class Guestbook(webapp.RequestHandler):
  def post(self):
    user = users.get_current_user()
    if user:
        name_str = user.nickname()
    else:
        name_str = 'anonymous'

    #self.response.out.write('<html><body>You wrote:<pre>')
    self.response.out.write('<html><body>%s wrote:<pre>'%name_str)
    self.response.out.write(cgi.escape(self.request.get('content')))
    self.response.out.write('</pre></body></html>')

def main():
  application = webapp.WSGIApplication(
                                       [('/', MainPage),
                                        ('/sign', Guestbook)],
                                       debug=True)
  wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
  main()

#app.yaml config script:

#application: helloworld
#version: 1
#runtime: python
#api_version: 1

#handlers:
#- url: /.*
  #script: helloworld.py

Got any questions?

Get answers in the ShowMeDo Learners Google Group.

Video statistics:

  • Video's rank shown in the most popular listing
  • Video plays: 125 (since July 30th)
  • Plays in last week: 0
  • Published: 78 months ago

Thank-yous, questions and comments

If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?

You may also want to see our ShowMeDo Google Group to speak to our active users and authors.

Your email address will not be published.

Show some quick comments >>








All comments excluding tick-boxed quick-comments

6. anonymous Tue, 13 Oct 2009 02:55

I am looking forward to reading this paper in detail. ,


Very nicely done. Great work.


This is the first time I watch a showmedo series based on an existing text-based tutorial. I found it rather enjoyable and adding value to the text-based tutorial. It would be really nice if you could take it beyond this last video in this series.

Thanks for your great work!


3. anonymous Fri, 04 Jul 2008 17:20

As the primary backer of HD DVD, Toshiba spent a lot of money developing technology that they didn't get a lot of use out of. Some features from HD DVD players, like upscaling, fit nicely into standard DVD players. Others, like web-enabled content, aren't quite as applicable. Sure you could put the same capabilities into a DVD player, but with no official standard you'd be hard pressed to get anyone to take advantage of it.


Useful video.

I was wondering what that initial comment meant in CGI terms. Glad you took the time to explain it at the end.


Video published, thanks for contributing to ShowMeDo


Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for Kyran

Content

Feedback

Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.

feedback@showmedo.com