Skip to content

Commit

Permalink
CORS headers for API
Browse files Browse the repository at this point in the history
  • Loading branch information
organisciak committed Feb 18, 2016
1 parent 8a07ebf commit 35cf1ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bookwormDB/bin/dbbindings-flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def main(JSONinput):
else:
resp.headers['Content-Type'] = "text/html"

resp.headers['Access-Control-Allow-Origin'] = '*'
resp.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, OPTIONS'
resp.headers['Access-Control-Allow-Headers'] = 'Origin, Accept, '\
'Content-Type, X-Requested-With, X-CSRF-Token'

return resp

if __name__ == '__main__':
Expand Down
6 changes: 6 additions & 0 deletions bookwormDB/bin/dbbindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
cgitb.enable()

def headers(method):

print 'Access-Control-Allow-Origin: *'
print 'Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS'
print 'Access-Control-Allow-Headers: Origin, Accept, Content-Type, ' \
'X-Requested-With, X-CSRF-Token'

if method!="return_tsv":
print "Content-type: text/html\n"

Expand Down

0 comments on commit 35cf1ef

Please sign in to comment.