1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-10 04:02:17 +00:00

Added header allowing web-clients using JSON to work

This commit is contained in:
spl0k 2015-08-15 16:07:28 +02:00
parent 5fdd28290b
commit 541efa6437

View File

@ -76,13 +76,15 @@ def authorize():
request.user = user
@app.after_request
def set_content_type(response):
def set_headers(response):
if not request.path.startswith('/rest/'):
return response
if response.mimetype.startswith('text'):
f = request.args.get('f')
response.headers['content-type'] = 'application/json' if f in [ 'jsonp', 'json' ] else 'text/xml'
response.headers['Content-Type'] = 'application/json' if f in [ 'jsonp', 'json' ] else 'text/xml'
response.headers['Access-Control-Allow-Origin'] = '*'
return response