فهرست منبع

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

+ 1 - 0
requirements.txt

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