From 4117346899f539b4637a0397d448cfda9bb08c70 Mon Sep 17 00:00:00 2001 From: seelpro <53879791+seelpro@users.noreply.github.com> Date: Tue, 23 Jan 2024 11:45:18 +0300 Subject: [PATCH] Add method-filter to routes, for separate use. @app.route('/', methods=['GET']) def get_func(): pass @app.route('/', methods=['POST']) def post_func(): pass --- picoweb/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/picoweb/__init__.py b/picoweb/__init__.py index b771121..623f0d8 100644 --- a/picoweb/__init__.py +++ b/picoweb/__init__.py @@ -167,8 +167,9 @@ def _handle(self, reader, writer): extra = {} if len(e) > 2: extra = e[2] - - if path == pattern: + _methods = extra.get("methods",[method]) + if (path == pattern) and \ + (method in _methods): found = True break elif not isinstance(pattern, str):