add option to inline logos
[mygpo-feedservice.git] / feedservice / main.py
blob21f8006cb90e4e725c716c962494ff5ee1671865
1 from google.appengine.ext import webapp
2 from google.appengine.ext.webapp.util import run_wsgi_app
4 import feeddownloader
5 import simplejson as json
7 class MainPage(webapp.RequestHandler):
8 def get(self):
9 self.response.headers['Content-Type'] = 'text/plain'
10 self.response.out.write('Hello, webapp World!')
12 class Parse(webapp.RequestHandler):
13 def get(self):
14 self.response.headers['Content-Type'] = 'text/plain'
15 urls = self.request.get_all('url')
16 inline_logo = self.is_set('inline_logo')
18 if urls:
19 podcasts = [feeddownloader.parse_feed(url, inline_logo) for url in urls]
20 pretty = json.dumps(podcasts, sort_keys=True, indent=4)
21 self.response.out.write(pretty)
22 else:
23 self.response.set_status(400)
24 self.response.out.write('parameter url missing')
26 def is_set(self, param, default='0'):
27 try:
28 return int(self.request.get(param, default))
29 except:
30 return 0
32 application = webapp.WSGIApplication([
33 ('/', MainPage),
34 ('/parse', Parse)
36 debug=True)
38 def main():
39 run_wsgi_app(application)
41 if __name__ == "__main__":
42 main()