Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Django Private Storage
Commits
bc7c5f63
Unverified
Commit
bc7c5f63
authored
Jan 31, 2018
by
Diederik van der Boor
Committed by
GitHub
Jan 31, 2018
Browse files
Merge pull request #17 from dr-mark/master
Add Python 2.x support for DjangoStreamingServer serve() method
parents
ce8b0b14
86632975
Changes
1
Hide whitespace changes
Inline
Side-by-side
private_storage/servers.py
View file @
bc7c5f63
...
...
@@ -2,6 +2,8 @@
Sending files efficiently for different kind of webservers.
"""
import
os
import
sys
import
time
from
django.conf
import
settings
from
django.core.exceptions
import
ImproperlyConfigured
...
...
@@ -41,7 +43,10 @@ class DjangoStreamingServer(object):
@
staticmethod
def
serve
(
private_file
):
# Support If-Last-Modified
mtime
=
private_file
.
modified_time
.
timestamp
()
if
sys
.
version_info
>=
(
3
,):
mtime
=
private_file
.
modified_time
.
timestamp
()
else
:
mtime
=
time
.
mktime
(
private_file
.
modified_time
.
timetuple
())
size
=
private_file
.
size
if
not
was_modified_since
(
private_file
.
request
.
META
.
get
(
'HTTP_IF_MODIFIED_SINCE'
),
mtime
,
size
):
return
HttpResponseNotModified
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment