Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 1.52 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env python
  2. #
  3. # Copyright 2007 Google Inc.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. #     http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. from google.appengine.ext import webapp
  18. from google.appengine.ext.webapp import util
  19. from django.utils import simplejson as json
  20. import urllib
  21. from suds.client import Client
  22. import logging
  23.  
  24. repustateURL = 'http://api.repustate.com/v1/demokey/clean-html.json?url='
  25.  
  26.  
  27. class MainHandler(webapp.RequestHandler):
  28.     def get(self):
  29.         try:
  30.             logging.debug("in MainHandler")
  31.  
  32.             articleURL = self.request.get("articleurl")
  33.             u = urllib.urlopen(repustateURL +articleURL)
  34.             data = u.read()
  35.             logging.debug(data)
  36.             self.response.out.write(json.dumps({'data':'data'}))
  37.         except Exception, e:
  38.             logging.error("Exception in get:" + str(e))
  39.  
  40. def main():
  41.     application = webapp.WSGIApplication([('/', MainHandler)],
  42.                                          debug=True)
  43.     util.run_wsgi_app(application)
  44.  
  45.  
  46. if __name__ == '__main__':
  47.     main()