option strip_html to remove HTML tags from text fields
[mygpo-feedservice.git] / feedservice / main.py
blobfb82ba8044d3818fafff40a20acf4cf1e627a27f
1 from google.appengine.ext import webapp
2 from google.appengine.ext.webapp.util import run_wsgi_app
4 import urllib
5 import feeddownloader
6 import simplejson as json
8 class MainPage(webapp.RequestHandler):
9 def get(self):
10 self.response.headers['Content-Type'] = 'text/plain'
11 self.response.out.write('Hello, webapp World!')
13 class Parse(webapp.RequestHandler):
15 def post(self):
16 return self.get()
18 def get(self):
19 self.response.headers['Content-Type'] = 'text/plain'
20 urls = self.request.get_all('url')
21 urls = map(urllib.unquote, urls)
22 inline_logo = self.request.get_range('inline_logo', 0, 1, default=0)
23 scale_to = self.request.get_range('scale_logo', 0, 1, default=0)
24 strip_html = self.request.get_range('strip_html', 0, 1, default=0)
25 modified = self.request.headers.get('If-Modified-Since', None)
27 if urls:
28 podcasts, last_modified = feeddownloader.parse_feeds(urls, inline_logo, scale_to, strip_html, modified)
29 pretty = json.dumps(podcasts, sort_keys=True, indent=4)
31 if last_modified:
32 from email import utils
33 import time
34 self.response.headers.add_header('Last-Modified', utils.formatdate(time.mktime(last_modified)))
36 self.response.out.write(pretty)
38 else:
39 self.response.set_status(400)
40 self.response.out.write('parameter url missing')
43 application = webapp.WSGIApplication([
44 ('/', MainPage),
45 ('/parse', Parse)
47 debug=True)
49 def main():
50 run_wsgi_app(application)
52 if __name__ == "__main__":
53 main()