-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcron.py
32 lines (25 loc) · 867 Bytes
/
cron.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import webapp2
import json
import urllib
import datetime
import feedparser
import utils
from google.appengine.ext.webapp import util
from model import InputFeed
from model import Entry
class FetchFeedsCronJob(webapp2.RequestHandler):
def get(self):
"""Loop through all feeds and fetches their entries"""
feeds = InputFeed.all().filter('deleted =', False)
self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
self.response.headers['Access-Control-Allow-Origin'] = '*'
count = 0
for feed in feeds:
count += 1
feed.fetch_entries(fetch_all=False)
self.response.out.write(json.dumps({
'nr_of_feeds_fetched': count,
}))
app = webapp2.WSGIApplication([
('/cron/fetch_feeds', FetchFeedsCronJob),
], debug=True)