Download - HTTP - Forms - AppEngine

Transcript
Page 1: HTTP - Forms - AppEngine

HTTP - Forms - AppEngine

Jim [email protected]

Page 2: HTTP - Forms - AppEngine

Making an HTTP request

•Connect to the server

•a "hand shake"

•Request a document (or the default document)

•GET http://dr-chuck.com/page1.htm

•GET http://www.mlive.com/ann-arbor/

•GET http://www.facebook.com

Page 3: HTTP - Forms - AppEngine

http://www.dr-chuck.com/page1.htm

protocol host document

Page 4: HTTP - Forms - AppEngine
Page 5: HTTP - Forms - AppEngine

Browser

Page 6: HTTP - Forms - AppEngine

Browser

Web Server

Page 7: HTTP - Forms - AppEngine

Browser

Web Server

GET http://www.dr-chuck.com/page2.htm

Page 8: HTTP - Forms - AppEngine

Browser

Web Server

GET http://www.dr-chuck.com/page2.htm

<h1>The Second Page</h1><p>If you like, you can switch back to the <a href="page1.htm">First Page</a>.</p>

Page 9: HTTP - Forms - AppEngine

Browser

Web Server

GET http://www.dr-chuck.com/page2.htm

<h1>The Second Page</h1><p>If you like, you can switch back to the <a href="page1.htm">First Page</a>.</p>

Page 10: HTTP - Forms - AppEngine

Browser

Web Server

GET http://www.dr-chuck.com/page2.htm

<h1>The Second Page</h1><p>If you like, you can switch back to the <a href="page1.htm">First Page</a>.</p>

An HTTP request - response cycle

Page 11: HTTP - Forms - AppEngine

Making an HTTP request

•Connect to the server

•a "hand shake"

•Request a document (or the default document)

•GET http://dr-chuck.com/page1.htm

•GET http://www.mlive.com/ann-arbor/

•GET http://www.facebook.com

Page 12: HTTP - Forms - AppEngine
Page 13: HTTP - Forms - AppEngine
Page 14: HTTP - Forms - AppEngine
Page 15: HTTP - Forms - AppEngine
Page 16: HTTP - Forms - AppEngine
Page 17: HTTP - Forms - AppEngine
Page 18: HTTP - Forms - AppEngine
Page 19: HTTP - Forms - AppEngine
Page 20: HTTP - Forms - AppEngine

Firebug helps again• If you haven't already installed Firebug, you need it now

• It can help explore the HTTP request-response cycle

•Some simple-looking pages involve lots of requests:

•HTML page(s)

• Image files

•CSS Style Sheets

• Javascript files

Page 21: HTTP - Forms - AppEngine
Page 22: HTTP - Forms - AppEngine
Page 23: HTTP - Forms - AppEngine
Page 24: HTTP - Forms - AppEngine

print "Your guess is", guess answer = 42 if guess < answer : print "Your guess is too low" if guess == answer : print "Congratulations!" if guess > answer : print "Your guess is too high"

Page 25: HTTP - Forms - AppEngine

print "Your guess is", guess answer = 42 if guess < answer : print "Your guess is too low" if guess == answer : print "Congratulations!" if guess > answer : print "Your guess is too high"

Logical expressions

True or false?

Page 26: HTTP - Forms - AppEngine
Page 27: HTTP - Forms - AppEngine

<p>Your guess is 20.</p> <p>Your guess is too low.</p> <form method="post" action="/"> <p> Enter Guess: <input type="text" name="guess" /> </p> <p> <input type="submit" /> </p> </form>

Page 28: HTTP - Forms - AppEngine

<p>Your guess is 20.</p> <p>Your guess is too low.</p> <form method="post" action="/"> <p> Enter Guess: <input type="text" name="guess" /> </p> <p> <input type="submit" /> </p> </form>

Page 29: HTTP - Forms - AppEngine

Attributes of a form element

• "action" attribute tells where to submit the form

•Usually the path to a script or program on the server that processes the form inputs

• "method" attribute tells how to submit the form

• In this case using HTTP POST

•See page 30 of RFC 1945

Page 30: HTTP - Forms - AppEngine

Intended purpose of POST

•Posting a message to a bulletin board, newsgroup, mailing list

•Annotation of existing resources

•Extending a database through an append operation

•Creating a new object

•Providing a block of data, such as the result of submitting a form

Page 31: HTTP - Forms - AppEngine

As opposed to GET

•Retrieve a resource identified by the path portion of the URL

Page 32: HTTP - Forms - AppEngine

Browser <input type="text" name="guess" />

Page 33: HTTP - Forms - AppEngine

Browser

Web Server

<input type="text" name="guess" />

Page 34: HTTP - Forms - AppEngine

POST /Accept: www/sourceAccept: text/htmlUser-Agent: Lynx/2.4 libwww/2.14Content-type: application/x-www-form-urlencodedContent-length: 8guess=25

HTTPRequest

Browser

Web Server

<input type="text" name="guess" />

Page 35: HTTP - Forms - AppEngine
Page 36: HTTP - Forms - AppEngine

POST /11

Page 37: HTTP - Forms - AppEngine

POST /11

22

Page 38: HTTP - Forms - AppEngine

POST /

<html> ...33

11

22

Page 39: HTTP - Forms - AppEngine
Page 40: HTTP - Forms - AppEngine

Text-1

Page 41: HTTP - Forms - AppEngine

Text

Page 42: HTTP - Forms - AppEngine

This is a job for ...

... Google App Engine

• Installing App Engine

•Demo of ae-01-trivial

•Demo of ae-01-guess

•Preview of next assignment