Skip to content

Commit d389013

Browse files
committed
Modified as_route docstring to be more verbose
1 parent 978a0c9 commit d389013

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

adafruit_httpserver/route.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ def as_route(
125125
"""
126126
Decorator used to convert a function into a ``Route`` object.
127127
128-
It is a shorthand for manually creating a ``Route`` object, that can be used only one time
129-
per function. Later it can be imported and registered in the ``Server``.
128+
``as_route`` can be only used once per function, because it replaces the function with
129+
a ``Route`` object that has the same name as the function.
130+
131+
Later it can be imported and registered in the ``Server``.
130132
131133
:param str path: URL path
132134
:param str methods: HTTP method(s): ``"GET"``, ``"POST"``, ``["GET", "POST"]`` etc.
@@ -142,6 +144,12 @@ def some_func(request):
142144
143145
some_func # Route(path="/example", methods={"GET"}, handler=<function some_func at 0x...>)
144146
147+
# WRONG: as_route can be used only once per function
148+
@as_route("/wrong-example1")
149+
@as_route("/wrong-example2")
150+
def wrong_func2(request):
151+
...
152+
145153
# If a route is in another file, you can import it and register it to the server
146154
147155
from .routes import some_func

0 commit comments

Comments
 (0)