瀏覽代碼

Added view for Home page articles.

Marco Quezada 10 年之前
父節點
當前提交
1370577848
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      hackathon_starter/hackathon/views.py

+ 6 - 0
hackathon_starter/hackathon/views.py

@@ -180,6 +180,12 @@ def nytimespop(request):
     popdata = fetcharticle(POPAPIKEY, 'http://api.nytimes.com/svc/mostpopular/v2/mostviewed/all-sections/1.json?')
     popdata = fetcharticle(POPAPIKEY, 'http://api.nytimes.com/svc/mostpopular/v2/mostviewed/all-sections/1.json?')
     return JSONResponse({'data': popdata})
     return JSONResponse({'data': popdata})
 
 
+def nytimestop(request):
+    '''Returns JSON response about the articles located in the homepage'''
+    TOPAPIKEY = 'c9655598e1fd4ff591f6d46f2321260e:17:71947444'
+    topdata = fetcharticle(TOPAPIKEY, 'http://api.nytimes.com/svc/topstories/v1/home.json?')
+    return JSONResponse({'data': topdata})
+
 #################
 #################
 #   GITHUB API  #
 #   GITHUB API  #
 #################
 #################