Return to Video

Hello Webapp World - Web Development

  • 0:00 - 0:03
    Okay, so let's move on to some live web applications.
  • 0:03 - 0:06
    So, at the end of your last homework, you should have
  • 0:06 - 0:10
    Google App Engine running on your machine, and you should have a basic site online.
  • 0:10 - 0:14
    We're going to start with basically the simple hello world example
  • 0:14 - 0:17
    that Google has on their site, which I have.
  • 0:17 - 0:22
    This is the main hello world Python file from the Google App Engine example page,
  • 0:22 - 0:24
    and it's got 2 main sections.
  • 0:24 - 0:26
    We'll start with this section down here at the bottom.
  • 0:26 - 0:29
    This is the URL mapping section, and in this case,
  • 0:29 - 0:33
    we have 1 URL, slash, and it maps to a handler called MainPage.
  • 0:33 - 0:36
    MainPage is defined in this class called MainPage.
  • 0:36 - 0:41
    It inherits from webapp to RequestHandler, which is the generic
  • 0:41 - 0:43
    request handler from Google.
  • 0:43 - 0:46
    If you don't know what classes are, you can learn about them offline.
  • 0:46 - 0:50
    It's basically a convenient way for grouping together
  • 0:50 - 0:52
    functions and data that are all related to the same thing.
  • 0:52 - 0:54
    We're not going to spend a whole lot of time on it here,
  • 0:54 - 0:56
    but you should be able to keep up just fine.
  • 0:56 - 0:58
    Our class has a function called get, which takes a parameter called self,
  • 0:58 - 1:04
    which is the common first parameter to most Python methods.
  • 1:04 - 1:07
    So, this function does 2 things.
  • 1:07 - 1:12
    First, it takes self.response, which is the kind of global response object
  • 1:12 - 1:16
    that this framework uses, and it sets a header.
  • 1:16 - 1:20
    It sets the Content-Type header to equal text/plain.
  • 1:20 - 1:24
    By default, the content type is text/html, but in this case it's setting it to text/plain,
  • 1:24 - 1:28
    and then it's writing the string "Hello, webapp World!"
  • 1:28 - 1:32
    If we start up Google App Engine, I'll start Google App Engine in my terminal here,
  • 1:32 - 1:37
    and then I'll go to my browser and load the page, and this is what we see.
  • 1:37 - 1:42
    We see that string that our program was writing out in our browser, "Hello, webapp World!"
  • 1:42 - 1:46
    Pretty neat.
Title:
Hello Webapp World - Web Development
Description:

more » « less
Video Language:
English
Team:
Udacity
Project:
CS253 - Web Development
Duration:
01:45

English subtitles

Revisions Compare revisions