Hi cloudg, In order to handle POST requests to your handler, you need to define a 'post' method that handles requests of that type. Any HTTP methods that you have not defined handlers for will return a 405 response.
-Nick Johnson On Wed, Aug 19, 2009 at 8:24 PM, cloudg <[email protected]> wrote: > > Hi all, > Iam trying to post data using fetchurl and then use the request > method, i get an error with HTTP 405 code. Both get and post do not > work, but what works is if i hardcode the values in the URL like ? > myhost=cool, it works. Please suggest. > > > To post data: (y.py) > > ------------------------------------------------------------------------------------- > from google.appengine.api import urlfetch > from google.appengine.api import apiproxy_stub_map > from google.appengine.api import urlfetch_stub > import urllib > > url = "http://myurl/" > apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() > apiproxy_stub_map.apiproxy.RegisterStub > ('urlfetch',urlfetch_stub.URLFetchServiceStub()) > > form_fields = { > "myhost": "cool", > "mysubject": "aid", > "email_address": "[email protected]" > } > form_data = urllib.urlencode(form_fields) > result = urlfetch.fetch(url=url, > payload=form_data, > method=urlfetch.POST, > headers={'Content-Type': 'application/x-www- > form-urlencoded'}) > > > ------------------------------------------------------------------------------------- > Read data after post (x.py) > > ------------------------------------------------------------------------------------- > from google.appengine.api import users > from google.appengine.ext import webapp > from google.appengine.api import mail > from google.appengine.ext.webapp.util import run_wsgi_app > > class MainPage(webapp.RequestHandler): > def get(self): > user = users.get_current_user() > host = self.request.get("myhost") > subj = self.request.get("mysubject") > to_addr = '[email protected]' > > application = webapp.WSGIApplication( > [('/', MainPage)], > debug=True) > > def main(): > run_wsgi_app(application) > > if __name__ == "__main__": > main() > > > > -- Nick Johnson, Developer Programs Engineer, App Engine --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
