title: GAE + Python2.7 + webapp2 + AJAX
body: <p>Are there any tutorials or code examples related to  AJAX implementation for GAE + Python2.7 + webapp2.</p>
  
  <p>I have tried to follow instructions below:</p>
  
  <p><a href="http://code.google.com/appengine/articles/rpc.html" rel="nofollow noreferrer">http://code.google.com/appengine/articles/rpc.html</a></p>
  
  <p>but I receive the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "E:\dev\workspace\test\webapp2.py", line 1536, in __call__
      rv = self.handle_exception(request, response, e)
    File "E:\dev\workspace\test\webapp2.py", line 1530, in __call__
      rv = self.router.dispatch(request, response)
    File "E:\dev\workspace\test\webapp2.py", line 1278, in default_dispatcher
      return route.handler_adapter(request, response)
    File "E:\dev\workspace\test\webapp2.py", line 1101, in __call__
      handler = self.handler(request, response)
  TypeError: __init__() takes exactly 1 argument (3 given)
  </code></pre>
  
  <p>There is another similar discussion here:</p>
  
  <p><a href="https://stackoverflow.com/questions/9354407/google-app-engine-python-protorpc-error-call-takes-exactly-1-argument-3">Google App Engine Python Protorpc Error: __call__() takes exactly 1 argument (3 given)</a></p>
  
  <p>heres is my code from  Specialscope's example:</p>
  
  <p><strong>main.py</strong></p>
  
  <pre><code>from BaseHandler import BaseHandler  
  from google.appengine.ext import blobstore  
  from google.appengine.ext.webapp import blobstore_handlers  
  import logging  
  from google.appengine.api import files  
  from google.appengine.api import images  
  import json  
  import webapp2
  
  class FileuploadHandler(BaseHandler):  
     def get(self):  
       blobstore.create_upload_url('/static')  
       context={}  
       self.render_response("uploader.html",**context)  
  class FileDownloadHandler(blobstore_handlers.BlobstoreUploadHandler,BaseHandler):  
     def post(self):  
       upload_files=self.request.POST  
       #image=upload_files['file']  
       logging.error(upload_files)  
       keys=upload_files.keys()  
       imageurls=[]  
       for key in keys:  
         if key.find("uploadimage")!=-1:  
           image=upload_files[key]  
           file_name=files.blobstore.create(mime_type='image/jpg')  
           with files.open(file_name,'a') as f:  
             f.write(image.value)  
           files.finalize(file_name)  
           blob_key=files.blobstore.get_blob_key(file_name)  
           imageurls.append(images.get_serving_url(blob_key))  
       context={}  
       context['imagelinks']=imageurls  
       self.response.write(json.dumps(context))  
  
  app = webapp2.WSGIApplication([
        ('/upload',                     FileuploadHandler),
        ('/download',                   FileDownloadHandler),
        ], debug = True)     
  </code></pre>
  
  <p><strong>BaseHandler.py</strong></p>
  
  <pre><code>import webapp2
  import os
  
  from webapp2_extras import jinja2
  from google.appengine.ext import db
  
  
  class BaseHandler(webapp2.RequestHandler):
  
      @webapp2.cached_property
      def jinja2(self):
          # Returns a Jinja2 renderer cached in the app registry.
          return jinja2.get_jinja2(app=self.app)
  
      def render_response(self, _template, **context):
          # Renders a template and writes the result to the response.
          rv = self.jinja2.render_template(_template, **context)
          self.response.write(rv)
  </code></pre>