diff --git a/apps/todo/__init__.py b/apps/todo/__init__.py index 97c2c990..4766d536 100644 --- a/apps/todo/__init__.py +++ b/apps/todo/__init__.py @@ -27,7 +27,7 @@ def index(): # example of GET/POST/DELETE RESTful APIs -@action("api") # a GET API function +@action("api", method="GET") # a GET API function @action.uses(session, db) # we load the session and db @action.uses(user_in_session) # then check we have a valid user in session def todo(): diff --git a/py4web/core.py b/py4web/core.py index 8b4e80fe..c7e56a77 100644 --- a/py4web/core.py +++ b/py4web/core.py @@ -1480,9 +1480,11 @@ def register_route(app_name, rule, kwargs, func): else: rule = url_prefix + rule dec_func = action.catch_errors(app_name, func) + if "method" not in kwargs: + kwargs["method"] = ["GET", "POST"] bottle.route(rule, **kwargs)(dec_func) filename = module2filename(func.__module__) - methods = kwargs.get("method", ["GET", "POST"]) + methods = kwargs.get("method") if isinstance(methods, str): methods = [methods] for method in methods: