@@ -71,19 +71,19 @@ Alternatively to using query parameters, you can use URL parameters.
71
71
72
72
In order to use URL parameters, you need to wrap them inside ``<> `` in ``HTTPServer.route ``, e.g. ``<my_parameter> ``.
73
73
74
- All URL parameters are passed as positional arguments to the handler function, in order they are specified.
74
+ All URL parameters are ** passed as positional (not keyword) arguments ** to the handler function, in order they are specified in `` HTTPServer.route `` .
75
75
76
76
Notice how the handler function in example below accepts two additional arguments : ``device_id `` and ``action ``.
77
77
78
78
If you specify multiple routes for single handler function and they have different number of URL parameters,
79
79
make sure to add default values for all the ones that might not be passed.
80
- In the example below the second route has only one URL parameter, so the ``action `` parameter has a default value of `` None `` .
80
+ In the example below the second route has only one URL parameter, so the ``action `` parameter has a default value.
81
81
82
82
Keep in mind that URL parameters are always passed as strings, so you need to convert them to the desired type.
83
83
Also note that the names of the function parameters **do not have to match ** with the ones used in route, but they **must ** be in the same order.
84
84
Look at the example below to see how the ``route_param_1 `` and ``route_param_1 `` are named differently in the handler function.
85
85
86
- Although it is possible, it makes more sens be consistent with the names of the parameters in the route and in the handler function.
86
+ Although it is possible, it makes more sense be consistent with the names of the parameters in the route and in the handler function.
87
87
88
88
.. literalinclude :: ../examples/httpserver_url_parameters.py
89
89
:caption: examples/httpserver_url_parameters.py
0 commit comments