Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신은섭(Shin Eun Seop)
/
2018-1-d.cloud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
10
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
신은섭(Shin Eun Seop)
2018-06-10 23:54:40 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5677cc9240989b9e9e65d65ab8da9fde2ff2c7c3
5677cc92
1 parent
62de3c7e
add session auth
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
dcloud/restful/views.py
dcloud/website/views.py
dcloud/restful/views.py
View file @
5677cc9
...
...
@@ -3,6 +3,9 @@ from django.contrib.auth.decorators import login_required
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
rest_framework
import
status
from
rest_framework.authentication
import
SessionAuthentication
,
BasicAuthentication
from
rest_framework.permissions
import
IsAuthenticated
from
restful
import
s3_interface
from
restful.models
import
File
...
...
@@ -12,6 +15,8 @@ class FileList(APIView):
"""
List all file, or create a new snippet.
"""
authentication_classes
=
(
SessionAuthentication
,
BasicAuthentication
)
permission_classes
=
(
IsAuthenticated
,)
"""
list files or view detail
...
...
@@ -53,6 +58,8 @@ class FileDetail(APIView):
"""
Download or delete a file instance.
"""
authentication_classes
=
(
SessionAuthentication
,
BasicAuthentication
)
permission_classes
=
(
IsAuthenticated
,)
def
get
(
self
,
request
,
path
=
"/"
,
format
=
None
):
# download file from s3
...
...
dcloud/website/views.py
View file @
5677cc9
...
...
@@ -12,6 +12,6 @@ def home(request):
@login_required
def
file_list
(
request
):
files
=
requests
.
get
(
'http://localhost:8000/restapi/list/'
)
print
(
fil
es
)
cookies
=
{
'sessionid'
:
request
.
session
.
session_key
}
files
=
requests
.
get
(
'http://localhost:8000/restapi/list/'
,
cookies
=
cooki
es
)
return
render
(
request
,
'website/file_list.html'
,
files
.
json
())
...
...
Please
register
or
login
to post a comment