diff --git a/new_routes.py b/new_routes.py index 560241d..2f2c2f3 100644 --- a/new_routes.py +++ b/new_routes.py @@ -10,18 +10,18 @@ class EnableCors(object): '''https://stackoverflow.com/a/17262900/1593536''' - name = 'enable_cors' - api = 2 - def apply(self, fn, context): - def _enable_cors(*args, **kwargs): - # set CORS headers - response.headers['Access-Control-Allow-Origin'] = '*' - response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, OPTIONS' - response.headers['Access-Control-Allow-Headers'] = 'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token' - if request.method != 'OPTIONS': - # actual request; reply with the actual response - return fn(*args, **kwargs) - return _enable_cors + name = 'enable_cors' + api = 2 + def apply(self, fn, context): + def _enable_cors(*args, **kwargs): + # set CORS headers + response.headers['Access-Control-Allow-Origin'] = '*' + response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, OPTIONS' + response.headers['Access-Control-Allow-Headers'] = 'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token' + if request.method != 'OPTIONS': + # actual request; reply with the actual response + return fn(*args, **kwargs) + return _enable_cors pdApp.install(EnableCors()) @root.route("/browse") @@ -46,19 +46,19 @@ def callback(): @root.route('/custom_images/') def callback(path): - return bot.static_file(path, f'{os.path.dirname(args.custom_routes)}/images/') + return bot.static_file(path, f'{os.path.dirname(args.custom_routes)}/images/') @root.route('/custom_css/') def callback(path): - return bot.static_file(path, f'{os.path.dirname(args.custom_routes)}/css/') + return bot.static_file(path, f'{os.path.dirname(args.custom_routes)}/css/') @root.route('/custom_js/') def callback(path): - return bot.static_file(path, f'{os.path.dirname(args.custom_routes)}/js/') + return bot.static_file(path, f'{os.path.dirname(args.custom_routes)}/js/') @root.route('/custom_data/') def callback(path): - return bot.static_file(path, f'{os.path.dirname(args.custom_routes)}/data/') + return bot.static_file(path, f'{os.path.dirname(args.custom_routes)}/data/') @root.route('/custom/giemsa_bands') def callback():