Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flaskdav
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
flaskdav
Commits
66719e14
Commit
66719e14
authored
Dec 16, 2015
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send response to GET method data chunk by chunk.
Flask doc:
http://flask.pocoo.org/docs/0.10/patterns/streaming/
parent
c4c453bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
flaskdav.py
flaskdav.py
+13
-5
No files found.
flaskdav.py
View file @
66719e14
from
itsdangerous
import
Signer
,
base64_encode
,
base64_decode
from
flask
import
Flask
,
request
,
render_template
,
make_response
,
g
from
flask
import
Flask
,
request
,
render_template
,
make_response
,
g
,
Response
from
flask.views
import
MethodView
import
urlparse
...
...
@@ -10,6 +10,8 @@ import os
app
=
Flask
(
__name__
.
split
(
'.'
)[
0
])
app
.
config
.
from_object
(
__name__
)
BUFFER_SIZE
=
128000
ALLOWED_METHODS
=
[
'GET'
,
'PUT'
,
'PROPFIND'
,
'PROPPATCH'
,
'MKCOL'
,
'DELETE'
,
'COPY'
,
'MOVE'
,
'OPTIONS'
]
...
...
@@ -175,10 +177,16 @@ class WebDAV(MethodView):
elif
os
.
path
.
isfile
(
localpath
):
try
:
data_resource
=
app
.
fs_handler
.
get_data
(
request
.
path
)
# TODO send large response by chunks would be nice for big
# files... http://flask.pocoo.org/docs/0.10/patterns/streaming/
data
=
data_resource
.
read
()
except
Exception
:
def
generate
():
data
=
data_resource
.
read
(
BUFFER_SIZE
)
while
data
:
debug
(
'get a chunk: '
+
data
)
yield
data
data
=
data_resource
.
read
(
BUFFER_SIZE
)
return
Response
(
response
=
generate
(),
status
=
response
.
status
,
headers
=
response
.
headers
)
except
Exception
,
e
:
debug
(
e
)
response
.
status
=
'500'
else
:
response
.
status
=
'404'
...
...
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