@@ -35,12 +35,12 @@ class UrlLibFetchHandler(webapp2.RequestHandler):
3535
3636 def get (self ):
3737 # [START urllib-get]
38- url = " http://www.google.com/"
38+ url = ' http://www.google.com/humans.txt'
3939 try :
4040 result = urllib2 .urlopen (url )
4141 self .response .write (result .read ())
42- except urllib2 .URLError , e :
43- logging .error ( " Caught exception fetching url {}" . format ( e ) )
42+ except urllib2 .URLError :
43+ logging .exception ( ' Caught exception fetching url' )
4444 # [END urllib-get]
4545
4646
@@ -49,24 +49,24 @@ class UrlFetchHandler(webapp2.RequestHandler):
4949
5050 def get (self ):
5151 # [START urlfetch-get]
52- url = " http://www.google.com/"
52+ url = ' http://www.google.com/humans.txt'
5353 try :
5454 result = urlfetch .fetch (url )
5555 if result .status_code == 200 :
5656 self .response .write (result .content )
5757 else :
5858 self .response .status_code = result .status_code
59- except urlfetch .Error , e :
60- logging .error ( " Caught exception fetching url {}" . format ( e ) )
59+ except urlfetch .Error :
60+ logging .exception ( ' Caught exception fetching url' )
6161 # [END urlfetch-get]
6262
6363
6464class UrlPostHandler (webapp2 .RequestHandler ):
6565 """ Demonstrates an HTTP POST form query using urlfetch"""
6666
6767 form_fields = {
68- " first_name" : " Albert" ,
69- " last_name" : " Johnson" ,
68+ ' first_name' : ' Albert' ,
69+ ' last_name' : ' Johnson' ,
7070 }
7171
7272 def get (self ):
@@ -75,13 +75,13 @@ def get(self):
7575 form_data = urllib .urlencode (UrlPostHandler .form_fields )
7676 headers = {'Content-Type' : 'application/x-www-form-urlencoded' }
7777 result = urlfetch .fetch (
78- url = " http://localhost:8080/submit_form" ,
78+ url = ' http://localhost:8080/submit_form' ,
7979 payload = form_data ,
8080 method = urlfetch .POST ,
8181 headers = headers )
8282 self .response .write (result .content )
83- except urlfetch .Error , e :
84- logging .error ( " Caught exception fetching url {}" . format ( e ) )
83+ except urlfetch .Error :
84+ logging .exception ( ' Caught exception fetching url' )
8585 # [END urlfetch-post]
8686
8787
0 commit comments