Skip to content

Instantly share code, notes, and snippets.

View diarmuidbourke's full-sized avatar

Diarmuid Bourke diarmuidbourke

  • RapidRatings
  • Dublin, Ireland
View GitHub Profile
@diarmuidbourke
diarmuidbourke / gist:5263452
Last active December 15, 2015 12:58
cors preflight response
def cors_tween_factory(handler, registry):
def handle_cors(request):
if request.method == "OPTIONS":
allowed_hosts = ['http://127.0.0.1:8000']
cors_headers = [
('Access-Control-Allow-Credentials', "true"),
('Access-Control-Allow-Origin', request.headers['origin']),
('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'),
('Access-Control-Allow-Headers',
"""X-CSRF-Token, X-Requested-With, Accept, """ +