fix docs example highlights

This commit is contained in:
foamyguy 2025-05-17 10:30:53 -05:00
parent fa365b0149
commit cd39addea8
2 changed files with 24 additions and 24 deletions

View file

@ -39,7 +39,7 @@ In order to save memory, we are unregistering unused MIME types and registering
.. literalinclude:: ../examples/httpserver_static_files_serving.py .. literalinclude:: ../examples/httpserver_static_files_serving.py
:caption: examples/httpserver_static_files_serving.py :caption: examples/httpserver_static_files_serving.py
:emphasize-lines: 12-18,23-26 :emphasize-lines: 11-17,22-25
:linenos: :linenos:
You can also serve a specific file from the handler. 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
.. literalinclude:: ../examples/httpserver_handler_serves_file.py .. literalinclude:: ../examples/httpserver_handler_serves_file.py
:caption: examples/httpserver_handler_serves_file.py :caption: examples/httpserver_handler_serves_file.py
:emphasize-lines: 13,22 :emphasize-lines: 12,21
:linenos: :linenos:
.. literalinclude:: ../examples/home.html .. literalinclude:: ../examples/home.html
@ -74,7 +74,7 @@ a running total of the last 10 samples.
.. literalinclude:: ../examples/httpserver_start_and_poll.py .. literalinclude:: ../examples/httpserver_start_and_poll.py
:caption: examples/httpserver_start_and_poll.py :caption: examples/httpserver_start_and_poll.py
:emphasize-lines: 29,38 :emphasize-lines: 28,37
:linenos: :linenos:
@ -86,7 +86,7 @@ without needing to manually manage the timing of each task.
.. literalinclude:: ../examples/httpserver_start_and_poll_asyncio.py .. literalinclude:: ../examples/httpserver_start_and_poll_asyncio.py
:caption: examples/httpserver_start_and_poll_asyncio.py :caption: examples/httpserver_start_and_poll_asyncio.py
:emphasize-lines: 5,33,42,45,50,55-62 :emphasize-lines: 5,6,34,43,46,51,56-63
:linenos: :linenos:
Server with MDNS Server with MDNS
@ -101,7 +101,7 @@ On some routers it is also possible to use ``http://custom-mdns-hostname:5000/``
.. literalinclude:: ../examples/httpserver_mdns.py .. literalinclude:: ../examples/httpserver_mdns.py
:caption: examples/httpserver_mdns.py :caption: examples/httpserver_mdns.py
:emphasize-lines: 12-14 :emphasize-lines: 11-13
:linenos: :linenos:
Get CPU information Get CPU information
@ -115,7 +115,7 @@ More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
.. literalinclude:: ../examples/httpserver_cpu_information.py .. literalinclude:: ../examples/httpserver_cpu_information.py
:caption: examples/httpserver_cpu_information.py :caption: examples/httpserver_cpu_information.py
:emphasize-lines: 9,15-18,33 :emphasize-lines: 9,14-17,32
:linenos: :linenos:
Handling different methods Handling different methods
@ -134,7 +134,7 @@ In example below, handler for ``/api`` and ``/api/`` route will be called when a
.. literalinclude:: ../examples/httpserver_methods.py .. literalinclude:: ../examples/httpserver_methods.py
:caption: examples/httpserver_methods.py :caption: examples/httpserver_methods.py
:emphasize-lines: 8,19,26,30,49 :emphasize-lines: 8,18,25,29,46
:linenos: :linenos:
Change NeoPixel color Change NeoPixel color
@ -156,7 +156,7 @@ Tested on ESP32-S2 Feather.
.. literalinclude:: ../examples/httpserver_neopixel.py .. literalinclude:: ../examples/httpserver_neopixel.py
:caption: examples/httpserver_neopixel.py :caption: examples/httpserver_neopixel.py
:emphasize-lines: 26-28,41,52,68,74 :emphasize-lines: 25-27,40,51,67,73
:linenos: :linenos:
Templates Templates
@ -209,7 +209,7 @@ return only the first one.
.. literalinclude:: ../examples/httpserver_form_data.py .. literalinclude:: ../examples/httpserver_form_data.py
:caption: examples/httpserver_form_data.py :caption: examples/httpserver_form_data.py
:emphasize-lines: 32,47,50 :emphasize-lines: 31,46,49
:linenos: :linenos:
Cookies Cookies
@ -223,7 +223,7 @@ In order to set cookies, pass ``cookies`` dictionary to ``Response`` constructo
.. literalinclude:: ../examples/httpserver_cookies.py .. literalinclude:: ../examples/httpserver_cookies.py
:caption: examples/httpserver_cookies.py :caption: examples/httpserver_cookies.py
:emphasize-lines: 70,74-75,82 :emphasize-lines: 69,73-74,81
:linenos: :linenos:
Chunked response Chunked response
@ -235,7 +235,7 @@ constructor.
.. literalinclude:: ../examples/httpserver_chunked.py .. literalinclude:: ../examples/httpserver_chunked.py
:caption: examples/httpserver_chunked.py :caption: examples/httpserver_chunked.py
:emphasize-lines: 8,21-26,28 :emphasize-lines: 8,20-25,27
:linenos: :linenos:
URL parameters and wildcards URL parameters and wildcards
@ -271,7 +271,7 @@ In both cases, wildcards will not match empty path segment, so ``/api/.../users`
.. literalinclude:: ../examples/httpserver_url_parameters.py .. literalinclude:: ../examples/httpserver_url_parameters.py
:caption: examples/httpserver_url_parameters.py :caption: examples/httpserver_url_parameters.py
:emphasize-lines: 30-34,53-54,65-66 :emphasize-lines: 29-31,48-49,60-61
:linenos: :linenos:
Authentication Authentication
@ -284,7 +284,7 @@ If you want to apply authentication to the whole server, you need to call ``.req
.. literalinclude:: ../examples/httpserver_authentication_server.py .. literalinclude:: ../examples/httpserver_authentication_server.py
:caption: examples/httpserver_authentication_server.py :caption: examples/httpserver_authentication_server.py
:emphasize-lines: 8,11-16,20 :emphasize-lines: 8,10-15,19
:linenos: :linenos:
On the other hand, if you want to apply authentication to a set of routes, you need to call ``require_authentication`` function. On the other hand, if you want to apply authentication to a set of routes, you need to call ``require_authentication`` function.
@ -292,7 +292,7 @@ In both cases you can check if ``request`` is authenticated by calling ``check_a
.. literalinclude:: ../examples/httpserver_authentication_handlers.py .. literalinclude:: ../examples/httpserver_authentication_handlers.py
:caption: examples/httpserver_authentication_handlers.py :caption: examples/httpserver_authentication_handlers.py
:emphasize-lines: 9-16,22-27,35,49,61 :emphasize-lines: 9-16,21-26,34,48,60
:linenos: :linenos:
Redirects Redirects
@ -309,7 +309,7 @@ Alternatively, you can pass a ``status`` object directly to ``Redirect`` constru
.. literalinclude:: ../examples/httpserver_redirects.py .. literalinclude:: ../examples/httpserver_redirects.py
:caption: examples/httpserver_redirects.py :caption: examples/httpserver_redirects.py
:emphasize-lines: 22-26,32,38,50,62 :emphasize-lines: 21-25,31,37,49,61
:linenos: :linenos:
Server-Sent Events Server-Sent Events
@ -329,7 +329,7 @@ response object somewhere, so that it can be accessed later.
.. literalinclude:: ../examples/httpserver_sse.py .. literalinclude:: ../examples/httpserver_sse.py
:caption: examples/httpserver_sse.py :caption: examples/httpserver_sse.py
:emphasize-lines: 10,17,46-53,63 :emphasize-lines: 11,17,46-53,63
:linenos: :linenos:
Websockets Websockets
@ -352,7 +352,7 @@ but it is recommended as it makes it easier to handle multiple tasks. It can be
.. literalinclude:: ../examples/httpserver_websocket.py .. literalinclude:: ../examples/httpserver_websocket.py
:caption: examples/httpserver_websocket.py :caption: examples/httpserver_websocket.py
:emphasize-lines: 12,20,65-72,88,99 :emphasize-lines: 14,21,66-73,89,100
:linenos: :linenos:
Custom response types e.g. video streaming Custom response types e.g. video streaming
@ -369,7 +369,7 @@ video to multiple clients while simultaneously handling other requests.
.. literalinclude:: ../examples/httpserver_video_stream.py .. literalinclude:: ../examples/httpserver_video_stream.py
:caption: examples/httpserver_video_stream.py :caption: examples/httpserver_video_stream.py
:emphasize-lines: 31-77,92 :emphasize-lines: 30-72,87
:linenos: :linenos:
HTTPS HTTPS
@ -389,7 +389,7 @@ and setting ``https=True``.
.. literalinclude:: ../examples/httpserver_https.py .. literalinclude:: ../examples/httpserver_https.py
:caption: examples/httpserver_https.py :caption: examples/httpserver_https.py
:emphasize-lines: 15-17 :emphasize-lines: 14-16
:linenos: :linenos:
@ -418,7 +418,7 @@ You can share same handler functions between servers or use different ones for e
.. literalinclude:: ../examples/httpserver_multiple_servers.py .. literalinclude:: ../examples/httpserver_multiple_servers.py
:caption: examples/httpserver_multiple_servers.py :caption: examples/httpserver_multiple_servers.py
:emphasize-lines: 13-14,16-17,20,28,36-37,48-49,54-55 :emphasize-lines: 12-13,15-16,19,27,35-36,47-48,53-54
:linenos: :linenos:
Debug mode Debug mode

View file

@ -22,7 +22,7 @@ it may not be able to access the internet.
.. literalinclude:: ../examples/httpserver_simpletest_manual_ap.py .. literalinclude:: ../examples/httpserver_simpletest_manual_ap.py
:caption: examples/httpserver_simpletest_manual_ap.py :caption: examples/httpserver_simpletest_manual_ap.py
:emphasize-lines: 11-16,30 :emphasize-lines: 10-15,29
:linenos: :linenos:
Manual Ethernet Manual Ethernet
@ -34,7 +34,7 @@ The only difference in usage is related to configuring the ``socket_source`` dif
.. literalinclude:: ../examples/httpserver_simpletest_manual_ethernet.py .. literalinclude:: ../examples/httpserver_simpletest_manual_ethernet.py
:caption: examples/httpserver_simpletest_manual_ethernet.py :caption: examples/httpserver_simpletest_manual_ethernet.py
:emphasize-lines: 9-10,13-25,38 :emphasize-lines: 7,10,12-24,37
:linenos: :linenos:
Automatic WiFi using ``settings.toml`` Automatic WiFi using ``settings.toml``
@ -62,7 +62,7 @@ Note that we still need to import ``socketpool`` and ``wifi`` modules.
.. literalinclude:: ../examples/httpserver_simpletest_auto_settings_toml.py .. literalinclude:: ../examples/httpserver_simpletest_auto_settings_toml.py
:caption: examples/httpserver_simpletest_auto_settings_toml.py :caption: examples/httpserver_simpletest_auto_settings_toml.py
:emphasize-lines: 11 :emphasize-lines: 10
:linenos: :linenos:
@ -78,5 +78,5 @@ You can read `more about it here <https://docs.circuitpython.org/projects/connec
.. literalinclude:: ../examples/httpserver_simpletest_auto_connection_manager.py .. literalinclude:: ../examples/httpserver_simpletest_auto_connection_manager.py
:caption: examples/httpserver_simpletest_auto_connection_manager.py :caption: examples/httpserver_simpletest_auto_connection_manager.py
:emphasize-lines: 7,11 :emphasize-lines: 6,10
:linenos: :linenos: