@@ -39,7 +39,7 @@ In order to save memory, we are unregistering unused MIME types and registering
39
39
40
40
.. literalinclude :: ../examples/httpserver_static_files_serving.py
41
41
:caption: examples/httpserver_static_files_serving.py
42
- :emphasize-lines: 12-18,23-26
42
+ :emphasize-lines: 11-17,22-25
43
43
:linenos:
44
44
45
45
You can also serve a specific file from the handler.
@@ -51,7 +51,7 @@ By doing that, you can serve files from multiple directories, and decide exactly
51
51
52
52
.. literalinclude :: ../examples/httpserver_handler_serves_file.py
53
53
:caption: examples/httpserver_handler_serves_file.py
54
- :emphasize-lines: 13,22
54
+ :emphasize-lines: 12,21
55
55
:linenos:
56
56
57
57
.. literalinclude :: ../examples/home.html
@@ -74,7 +74,7 @@ a running total of the last 10 samples.
74
74
75
75
.. literalinclude :: ../examples/httpserver_start_and_poll.py
76
76
:caption: examples/httpserver_start_and_poll.py
77
- :emphasize-lines: 29,38
77
+ :emphasize-lines: 28,37
78
78
:linenos:
79
79
80
80
@@ -86,7 +86,7 @@ without needing to manually manage the timing of each task.
86
86
87
87
.. literalinclude :: ../examples/httpserver_start_and_poll_asyncio.py
88
88
:caption: examples/httpserver_start_and_poll_asyncio.py
89
- :emphasize-lines: 5,33,42,45,50,55-62
89
+ :emphasize-lines: 5,6,34,43,46,51,56-63
90
90
:linenos:
91
91
92
92
Server with MDNS
@@ -101,7 +101,7 @@ On some routers it is also possible to use ``http://custom-mdns-hostname:5000/``
101
101
102
102
.. literalinclude :: ../examples/httpserver_mdns.py
103
103
:caption: examples/httpserver_mdns.py
104
- :emphasize-lines: 12-14
104
+ :emphasize-lines: 11-13
105
105
:linenos:
106
106
107
107
Get CPU information
@@ -115,7 +115,7 @@ More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
115
115
116
116
.. literalinclude :: ../examples/httpserver_cpu_information.py
117
117
:caption: examples/httpserver_cpu_information.py
118
- :emphasize-lines: 9,15-18,33
118
+ :emphasize-lines: 9,14-17,32
119
119
:linenos:
120
120
121
121
Handling different methods
@@ -134,7 +134,7 @@ In example below, handler for ``/api`` and ``/api/`` route will be called when a
134
134
135
135
.. literalinclude :: ../examples/httpserver_methods.py
136
136
:caption: examples/httpserver_methods.py
137
- :emphasize-lines: 8,19,26,30,49
137
+ :emphasize-lines: 8,18,25,29,46
138
138
:linenos:
139
139
140
140
Change NeoPixel color
@@ -156,7 +156,7 @@ Tested on ESP32-S2 Feather.
156
156
157
157
.. literalinclude :: ../examples/httpserver_neopixel.py
158
158
:caption: examples/httpserver_neopixel.py
159
- :emphasize-lines: 26-28,41,52,68,74
159
+ :emphasize-lines: 25-27,40,51,67,73
160
160
:linenos:
161
161
162
162
Templates
@@ -209,7 +209,7 @@ return only the first one.
209
209
210
210
.. literalinclude :: ../examples/httpserver_form_data.py
211
211
:caption: examples/httpserver_form_data.py
212
- :emphasize-lines: 32,47,50
212
+ :emphasize-lines: 31,46,49
213
213
:linenos:
214
214
215
215
Cookies
@@ -223,7 +223,7 @@ In order to set cookies, pass ``cookies`` dictionary to ``Response`` constructo
223
223
224
224
.. literalinclude :: ../examples/httpserver_cookies.py
225
225
:caption: examples/httpserver_cookies.py
226
- :emphasize-lines: 70,74-75,82
226
+ :emphasize-lines: 69,73-74,81
227
227
:linenos:
228
228
229
229
Chunked response
@@ -235,7 +235,7 @@ constructor.
235
235
236
236
.. literalinclude :: ../examples/httpserver_chunked.py
237
237
:caption: examples/httpserver_chunked.py
238
- :emphasize-lines: 8,21-26,28
238
+ :emphasize-lines: 8,20-25,27
239
239
:linenos:
240
240
241
241
URL parameters and wildcards
@@ -271,7 +271,7 @@ In both cases, wildcards will not match empty path segment, so ``/api/.../users`
271
271
272
272
.. literalinclude :: ../examples/httpserver_url_parameters.py
273
273
:caption: examples/httpserver_url_parameters.py
274
- :emphasize-lines: 30-34,53-54,65-66
274
+ :emphasize-lines: 29-31,48-49,60-61
275
275
:linenos:
276
276
277
277
Authentication
@@ -284,15 +284,15 @@ If you want to apply authentication to the whole server, you need to call ``.req
284
284
285
285
.. literalinclude :: ../examples/httpserver_authentication_server.py
286
286
:caption: examples/httpserver_authentication_server.py
287
- :emphasize-lines: 8,11-16,20
287
+ :emphasize-lines: 8,10-15,19
288
288
:linenos:
289
289
290
290
On the other hand, if you want to apply authentication to a set of routes, you need to call ``require_authentication `` function.
291
291
In both cases you can check if ``request `` is authenticated by calling ``check_authentication `` on it.
292
292
293
293
.. literalinclude :: ../examples/httpserver_authentication_handlers.py
294
294
:caption: examples/httpserver_authentication_handlers.py
295
- :emphasize-lines: 9-16,22-27,35,49,61
295
+ :emphasize-lines: 9-16,21-26,34,48,60
296
296
:linenos:
297
297
298
298
Redirects
@@ -309,7 +309,7 @@ Alternatively, you can pass a ``status`` object directly to ``Redirect`` constru
309
309
310
310
.. literalinclude :: ../examples/httpserver_redirects.py
311
311
:caption: examples/httpserver_redirects.py
312
- :emphasize-lines: 22-26,32,38,50,62
312
+ :emphasize-lines: 21-25,31,37,49,61
313
313
:linenos:
314
314
315
315
Server-Sent Events
@@ -329,7 +329,7 @@ response object somewhere, so that it can be accessed later.
329
329
330
330
.. literalinclude :: ../examples/httpserver_sse.py
331
331
:caption: examples/httpserver_sse.py
332
- :emphasize-lines: 10 ,17,46-53,63
332
+ :emphasize-lines: 11 ,17,46-53,63
333
333
:linenos:
334
334
335
335
Websockets
@@ -352,7 +352,7 @@ but it is recommended as it makes it easier to handle multiple tasks. It can be
352
352
353
353
.. literalinclude :: ../examples/httpserver_websocket.py
354
354
:caption: examples/httpserver_websocket.py
355
- :emphasize-lines: 12,20,65-72,88,99
355
+ :emphasize-lines: 14,21,66-73,89,100
356
356
:linenos:
357
357
358
358
Custom response types e.g. video streaming
@@ -369,7 +369,7 @@ video to multiple clients while simultaneously handling other requests.
369
369
370
370
.. literalinclude :: ../examples/httpserver_video_stream.py
371
371
:caption: examples/httpserver_video_stream.py
372
- :emphasize-lines: 31-77,92
372
+ :emphasize-lines: 30-72,87
373
373
:linenos:
374
374
375
375
HTTPS
@@ -389,7 +389,7 @@ and setting ``https=True``.
389
389
390
390
.. literalinclude :: ../examples/httpserver_https.py
391
391
:caption: examples/httpserver_https.py
392
- :emphasize-lines: 15-17
392
+ :emphasize-lines: 14-16
393
393
:linenos:
394
394
395
395
@@ -418,7 +418,7 @@ You can share same handler functions between servers or use different ones for e
418
418
419
419
.. literalinclude :: ../examples/httpserver_multiple_servers.py
420
420
:caption: examples/httpserver_multiple_servers.py
421
- :emphasize-lines: 13-14,16-17,20,28,36-37,48-49,54-55
421
+ :emphasize-lines: 12-13,15-16,19,27,35-36,47-48,53-54
422
422
:linenos:
423
423
424
424
Debug mode
0 commit comments