diff options
| author | Fulgen301 <tokmajigeorge@gmail.com> | 2018-10-16 18:57:01 +0200 |
|---|---|---|
| committer | Fulgen301 <tokmajigeorge@gmail.com> | 2018-10-16 18:57:01 +0200 |
| commit | 8213c244eaca9a65a51ccb8422b3adb45485ef43 (patch) | |
| tree | d8f22d6e91aa869e8ab51b5d5bf6de5de2824881 /helpers.py | |
| parent | 28afed69d3f5a04c86aa87ad18e15ec55bdc7a82 (diff) | |
| download | parry-8213c244eaca9a65a51ccb8422b3adb45485ef43.tar.gz parry-8213c244eaca9a65a51ccb8422b3adb45485ef43.zip | |
Subclass HTTPReponse in order to ensure the presence of CORS headers
Diffstat (limited to 'helpers.py')
| -rw-r--r-- | helpers.py | 13 |
1 files changed, 2 insertions, 11 deletions
@@ -16,7 +16,7 @@ import sys import os, re, json, math import requests from bson.objectid import ObjectId -from bottle import install, run, Bottle, static_file, response, hook, JSONPlugin, get, post, error +from bottle import install, run, Bottle, static_file, JSONPlugin, get, post, error import threading class ParryEncoder(json.JSONEncoder): @@ -31,7 +31,7 @@ install(JSONPlugin(json_dumps=lambda s: json.dumps(s, cls=ParryEncoder))) os.chdir(os.path.dirname(__file__)) from .auth import * - + def calculateHashForResource(resource : requests.Response) -> object: hashobj = hashlib.sha1() @@ -53,15 +53,6 @@ def calculateHashForFile(file, hashobj : object = None) -> object: return hashobj -@route("<path:path>", method="OPTIONS") -def options(path): - return HTTPResponse(status=204, headers={"Access-Control-Allow-Origin" : "*", "Access-Control-Allow-Methods" : "GET, POST, HEAD, PUT, PATCH, DELETE", "Access-Control-Allow-Headers" : "*"}) - -@hook("after_request") -def enable_cors(): - response.headers["Access-Control-Allow-Origin"] = "*" - response.headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, PATCH, HEAD" - @error(500) def internal_error(error): if request.json is None: |
