Python: Using Python AppEngine as a Proxy for Twitter


/ Published in: Python
Save to your folder(s)

In order to pull data out of Twitter using Flex, I need a proxy script. Here's how I did it using Python and Google App Engine


Copy this code and paste it in your HTML
  1. import os
  2. #Python's standard Web Application Container
  3. import wsgiref.handlers
  4. #Template Renderder
  5. from apptools import AppHandler
  6. #Google's App Engine
  7. from google.appengine.ext import webapp
  8.  
  9. import urllib2
  10. from urllib2 import urlopen
  11.  
  12. class RedirectHandler(webapp.RequestHandler):
  13. def get(self):
  14. data = urlopen( "http://twitter.com/statuses/user_timeline/chrisaiv.xml?count=10" )
  15. d = data.read();
  16. self.response.out.write( d );
  17.  
  18. def main():
  19. application = webapp.WSGIApplication([
  20. ('/twitterproxy', RedirectHandler),
  21. debug=True)
  22. wsgiref.handlers.CGIHandler().run(application)
  23.  
  24.  
  25. if __name__ == '__main__':
  26. main()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.