Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Pawan Kumar
/
general
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 67b101e4
authored
Mar 23, 2018
by
sakeer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
committed all files
1 parent
c138e40f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
20 deletions
github/github/urls.py
github/github/urls.pyc
github/github/views.py
github/github/views.pyc
github/github/urls.py
View file @
67b101e
...
...
@@ -15,9 +15,9 @@ Including another URLconf
"""
from
django.conf.urls
import
url
from
django.contrib
import
admin
from
views
import
index
from
views
import
Home
from
django.contrib.auth
import
views
urlpatterns
=
[
url
(
r'^admin/'
,
admin
.
site
.
urls
),
url
(
r'^$'
,
index
,
name
=
'index'
),
url
(
r'^$'
,
Home
.
as_view
()
,
name
=
'index'
),
]
github/github/urls.pyc
View file @
67b101e
No preview for this file type
github/github/views.py
View file @
67b101e
...
...
@@ -2,24 +2,32 @@ import requests
import
urllib
from
django.shortcuts
import
render
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views
import
View
url
=
'https://api.github.com/search/repositories'
params
=
{
'access_token'
:
'f7d4d8cf047417964e1b4d9f829490a7fdeb6186'
}
@csrf_exempt
def
index
(
request
):
"""
Documentation
class
Home
(
View
):
"""
if
request
.
method
==
'POST'
:
result
=
{}
languages
=
[]
Description: This class is used to show the urls and desription of the github results
Author : Sakeer P
Created At: 23rd March 2018
"""
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
return
render
(
request
,
'index.html'
)
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
result
=
{}
self
.
languages
=
[]
results
=
requests
.
get
(
url
+
'?'
+
urllib
.
urlencode
(
params
)
+
'&q='
+
request
.
POST
[
'search'
])
result
=
results
.
json
()
if
'items'
in
result
:
for
key
in
result
[
'items'
]:
languages
.
append
(
key
[
'language'
])
languages
=
list
(
set
(
languages
))
return
render
(
request
,
'index.html'
,{
'data'
:
result
[
'items'
],
'languages'
:
languages
})
else
:
return
render
(
request
,
'index.html'
)
\ No newline at end of file
self
.
result
=
results
.
json
()
if
'items'
in
self
.
result
:
for
key
in
self
.
result
[
'items'
]:
self
.
languages
.
append
(
key
[
'language'
])
self
.
languages
=
list
(
set
(
self
.
languages
))
return
render
(
request
,
'index.html'
,{
'data'
:
self
.
result
[
'items'
],
'languages'
:
self
.
languages
})
\ No newline at end of file
github/github/views.pyc
View file @
67b101e
No preview for this file type
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment