Skip to content

Commit aad6f1b

Browse files
committed
add cross origin header for fileupload
1 parent f6880ed commit aad6f1b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ def fileget():
218218
"""Returns the file data of the file indicated by the query parameters."""
219219
return static_file(resolve_file(), root=settings.BASE_DIR)
220220

221+
@route('/fileupload', method='OPTIONS')
222+
def fileupload_options():
223+
response.set_header('Access-Control-Allow-Origin', '*')
224+
response.content_type = "text/plain; charset=utf-8"
225+
return ''
226+
221227
@route('/fileupload', method='POST')
222228
@require_token('store')
223229
def fileupload():
@@ -238,6 +244,7 @@ def fileupload():
238244
upload = request.files.values()[0]
239245
upload.save(pathname, overwrite=True)
240246

247+
response.set_header('Access-Control-Allow-Origin', '*')
241248
response.content_type = 'text/plain; charset=utf-8'
242249
return 'Ok.'
243250

0 commit comments

Comments
 (0)