diff --git a/couchpotato/__init__.py b/couchpotato/__init__.py index aee03823..8dc691da 100644 --- a/couchpotato/__init__.py +++ b/couchpotato/__init__.py @@ -20,7 +20,8 @@ template_loader = template.Loader(os.path.join(os.path.dirname(__file__), 'templ # Main web handler @requires_auth class WebHandler(RequestHandler): - def get(self, route): + def get(self, route, *args, **kwargs): + route = route.strip('/') if not views.get(route): page_not_found(self) return @@ -55,7 +56,7 @@ addView('docs', apiDocs) # Make non basic auth option to get api key class KeyHandler(RequestHandler): - def get(self): + def get(self, *args, **kwargs): api = None username = Env.setting('username') password = Env.setting('password') diff --git a/couchpotato/api.py b/couchpotato/api.py index 20eaa332..93d8a251 100644 --- a/couchpotato/api.py +++ b/couchpotato/api.py @@ -14,7 +14,8 @@ class NonBlockHandler(RequestHandler): stoppers = [] @asynchronous - def get(self, route): + def get(self, route, *args, **kwargs): + route = route.strip('/') start, stop = api_nonblock[route] self.stoppers.append(stop) @@ -43,7 +44,8 @@ def addNonBlockApiView(route, func_tuple, docs = None, **kwargs): # Blocking API handler class ApiHandler(RequestHandler): - def get(self, route): + def get(self, route, *args, **kwargs): + route = route.strip('/') if not api.get(route): self.write('API call doesn\'t seem to exist') return diff --git a/couchpotato/core/auth.py b/couchpotato/core/auth.py index b987f451..e58016bd 100644 --- a/couchpotato/core/auth.py +++ b/couchpotato/core/auth.py @@ -38,14 +38,3 @@ def requires_auth(handler_class): handler_class._execute = wrap_execute(handler_class._execute) return handler_class - -# @wraps(f) -# def decorated(*args, **kwargs): -# auth = getattr(request, 'authorization') -# if Env.setting('username') and Env.setting('password'): -# if (not auth or not check_auth(auth.username.decode('latin1'), md5(auth.password.decode('latin1').encode(Env.get('encoding'))))): -# return authenticate() -# -# return f(*args, **kwargs) -# -# return decorated diff --git a/couchpotato/runner.py b/couchpotato/runner.py index fd05049a..0c0127fa 100644 --- a/couchpotato/runner.py +++ b/couchpotato/runner.py @@ -230,16 +230,15 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En # Request handlers application.add_handlers(".*$", [ - (r'%snonblock/(.*)/' % api_base, NonBlockHandler), + (r'%snonblock/(.*)(/?)' % api_base, NonBlockHandler), # API handlers - (r'%s(.*)/' % api_base, ApiHandler), # Main API handler - (r'%sgetkey/' % web_base, KeyHandler), # Get API key + (r'%s(.*)(/?)' % api_base, ApiHandler), # Main API handler + (r'%sgetkey(/?)' % web_base, KeyHandler), # Get API key (r'%s' % api_base, RedirectHandler, {"url": web_base + 'docs/'}), # API docs # Catch all webhandlers - (r'%s(.*)/' % web_base, WebHandler), - (r'%s(.*)' % web_base, WebHandler), + (r'%s(.*)(/?)' % web_base, WebHandler), (r'(.*)', WebHandler), ])