-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
33 lines (27 loc) · 858 Bytes
/
views.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
33
# Response
from django.http import Http404
# Views
from django.views.generic.simple import direct_to_template
HEADLINES = {
'google': 'Trending on Google',
'twitter': 'Trending on Twitter',
}
FEEDS = {
'google': 'http://pipes.yahoo.com/pipes/pipe.run?_id=OtSAI5r83BGLeywRG8evXg&_render=rss',
'twitter': 'http://pipes.yahoo.com/pipes/pipe.run?_id=bk_UedF43hGMQh2FqevxTA&_render=rss',
}
def index(request):
"""
Returns a feed page, depending on the querystring.
"""
# Figure out what page we're serving
slug = request.GET.get('feed', 'google')
if slug not in HEADLINES.keys():
raise Http404
# Pass out the proper data
context = {
'headline': HEADLINES[slug],
'feed_url': FEEDS[slug],
}
template = 'feeds/index.html'
return direct_to_template(request, template, context)