Quiz: Writing a Basic Form

Intro to Backend >> Templates >> Quiz: Writing  Basic Form

Here is how to create a new application:

  1. Go to the folder in which you saved the last application, “hello-udacity”
  2. Create a new folder called “templates”
  3. Open up your code editor (ex: Sublime Text 2) and save a file called main.py into the templates folder you created in Step 2. I copied the text the teacher shows on the video for you. Here it is, it is what you will input into main.py:
    import os
    
    import webapp2
    
    class Handler(webapp2.RequestHandler):
            def write(self, *a, **kw):
                self.response.out.write(*a, **kw)
    
    class MainPage(Handler):
        def get(self):
            self.write("Hello, Udacity!")
    
    app = webapp2.WSGIApplication([('/', MainPage)
                                   ],
                                  debug=True)
    
  4. Save main.py. Create another file, save it as “app.yaml”. I copied the text the teacher shows from the video, with a slight change. See if you can find it. Input this into app.yaml:
    application: templates
    version: 1
    runtime: python27
    api_version: 1
    threadsafe: true
    
    handlers:
    - url: .*
      script: main.app
    
  5. Create one more file called “main.pyc”. Leave it blank.
  6. Open GoogleAppEngine Launcher if it is not already open. File >> Add Existing Application… Click “Browse”. Select the new folder templates you just made. Stop any other applications running by clicking them and then click Stop. Once all other applications are stopped (probably just the hello-udacity one is all you have to worry about), then click the templates one we just added, and click run. If it worked, you should be able to open it in Chrome with its local port:8080, while 8080 could be also 9080, or 10080, you need to look at Google AppEngine Launcher and look at templates to see the number associated with it. If it all worked, the page should say this:Hello, Udacity!
Advertisements

Author: ajoannaproject

Studying Udacity's Full Stack Web Developer program and passing on my improvements, hints, hacks, and updates to other students via ajoannaproject.wordpress.com.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s