瀏覽代碼

Working on Github API example

David Leonard 10 年之前
父節點
當前提交
2858226e73
共有 3 個文件被更改,包括 27 次插入0 次删除
  1. 23 0
      hackathon_starter/hackathon/scripts/github.py
  2. 3 0
      hackathon_starter/hackathon/views.py
  3. 1 0
      requirements.txt

+ 23 - 0
hackathon_starter/hackathon/scripts/github.py

@@ -0,0 +1,23 @@
+'''
+Module github.py contains a handful of methods
+for interacting with Github data.
+'''
+
+import requests
+import simplejson as json
+
+########################
+# GITHUB API CONSTANTS #
+########################
+
+API_BASE_URL = 'https://api.github.com/'
+API_USERS_URL = API_BASE_URL + 'users/DrkSephy'
+
+def getUserData():
+	req = requests.get(API_USERS_URL)
+	jsonList = []
+	jsonList.append(json.loads(req.content))
+	print jsonList
+	
+	
+	

+ 3 - 0
hackathon_starter/hackathon/views.py

@@ -5,6 +5,7 @@ from django.template import RequestContext, loader
 from django.contrib.auth import authenticate, login
 from django.http import HttpResponse, HttpResponseRedirect
 from scripts.steam import gamesPulling, steamIDPulling 
+from scripts.github import getUserData
 
 
 def index(request):
@@ -116,6 +117,8 @@ def steam(request):
     return render(request,'hackathon/steam.html', {"game": game })
 
 def github(request):
+    data = getUserData()
+    print data
     context = {'title': 'Github Example'}
     return render(request, 'hackathon/github.html', context)
 

+ 1 - 0
requirements.txt

@@ -11,5 +11,6 @@ nose==1.3.4
 pylint==1.4.3
 python-openid==2.2.5
 requests==2.6.0
+simplejson==3.6.5
 six==1.9.0
 wsgiref==0.1.2