Sending HTTP requests from App Engine

Can I send HTTP requests from the AppEngine app? I need to do some queries and pull some data from other sites.

+2


a source to share


1 answer


Yes. More details here: http://code.google.com/appengine/docs/python/urlfetch/overview.html

You can use the Python standard urllib, urllib2, or httplib libraries to make HTTP requests. When App Engine starts, these libraries make HTTP requests using the App Engine URL of the fetch service, which runs on Google's Scalable HTTP Request Framework.



Here's an example:

import urllib
from xml.dom import minidom
from google.appengine.api import urlfetch

params = urllib.urlencode({'p': loc_param, 'u': units,})
full_uri = '?'.join([url, params,])

result = urlfetch.fetch(full_uri)
if result.status_code == 200:
    return minidom.parseString(result.content)

      

+4


a source







All Articles