adafruit-circuitpython-httpserver 4.5.7__tar.gz → 4.5.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/PKG-INFO +1 -1
  2. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_circuitpython_httpserver.egg-info/PKG-INFO +1 -1
  3. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_circuitpython_httpserver.egg-info/SOURCES.txt +7 -4
  4. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/__init__.py +1 -1
  5. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/docs/examples.rst +13 -42
  6. adafruit_circuitpython_httpserver-4.5.8/docs/starting_methods.rst +82 -0
  7. adafruit_circuitpython_httpserver-4.5.8/docs/starting_methods.rst.license +3 -0
  8. adafruit_circuitpython_httpserver-4.5.8/examples/httpserver_simpletest_auto_connection_manager.py +23 -0
  9. adafruit_circuitpython_httpserver-4.5.8/examples/httpserver_simpletest_manual_ap.py +30 -0
  10. adafruit-circuitpython-httpserver-4.5.7/examples/httpserver_ethernet_simpletest.py → adafruit_circuitpython_httpserver-4.5.8/examples/httpserver_simpletest_manual_ethernet.py +4 -3
  11. adafruit-circuitpython-httpserver-4.5.7/examples/httpserver_simpletest_manual.py → adafruit_circuitpython_httpserver-4.5.8/examples/httpserver_simpletest_manual_wifi.py +6 -7
  12. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/pyproject.toml +1 -1
  13. adafruit-circuitpython-httpserver-4.5.7/examples/httpserver_simpletest_connectionmanager.py +0 -33
  14. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md +0 -0
  15. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/.github/workflows/build.yml +0 -0
  16. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/.github/workflows/failure-help-text.yml +0 -0
  17. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/.github/workflows/release_gh.yml +0 -0
  18. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/.github/workflows/release_pypi.yml +0 -0
  19. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/.gitignore +0 -0
  20. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/.pre-commit-config.yaml +0 -0
  21. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/.pylintrc +0 -0
  22. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/.readthedocs.yaml +0 -0
  23. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/CODE_OF_CONDUCT.md +0 -0
  24. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/LICENSE +0 -0
  25. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/LICENSES/CC-BY-4.0.txt +0 -0
  26. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/LICENSES/MIT.txt +0 -0
  27. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/LICENSES/Unlicense.txt +0 -0
  28. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/README.rst +0 -0
  29. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/README.rst.license +0 -0
  30. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_circuitpython_httpserver.egg-info/dependency_links.txt +0 -0
  31. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_circuitpython_httpserver.egg-info/requires.txt +0 -0
  32. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_circuitpython_httpserver.egg-info/top_level.txt +0 -0
  33. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/authentication.py +0 -0
  34. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/exceptions.py +0 -0
  35. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/headers.py +0 -0
  36. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/interfaces.py +0 -0
  37. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/methods.py +0 -0
  38. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/mime_types.py +0 -0
  39. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/request.py +0 -0
  40. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/response.py +0 -0
  41. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/route.py +0 -0
  42. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/server.py +0 -0
  43. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/adafruit_httpserver/status.py +0 -0
  44. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/docs/_static/favicon.ico +0 -0
  45. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/docs/_static/favicon.ico.license +0 -0
  46. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/docs/api.rst +0 -0
  47. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/docs/api.rst.license +0 -0
  48. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/docs/conf.py +0 -0
  49. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/docs/examples.rst.license +0 -0
  50. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/docs/index.rst +0 -0
  51. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/docs/index.rst.license +0 -0
  52. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/docs/requirements.txt +0 -0
  53. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/directory_listing.tpl.html +0 -0
  54. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/home.html +0 -0
  55. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_authentication_handlers.py +0 -0
  56. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_authentication_server.py +0 -0
  57. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_chunked.py +0 -0
  58. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_cookies.py +0 -0
  59. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_cpu_information.py +0 -0
  60. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_cpython.py +0 -0
  61. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_form_data.py +0 -0
  62. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_handler_serves_file.py +0 -0
  63. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_mdns.py +0 -0
  64. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_methods.py +0 -0
  65. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_multiple_servers.py +0 -0
  66. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_neopixel.py +0 -0
  67. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_redirects.py +0 -0
  68. /adafruit-circuitpython-httpserver-4.5.7/examples/httpserver_simpletest_auto.py → /adafruit_circuitpython_httpserver-4.5.8/examples/httpserver_simpletest_auto_settings_toml.py +0 -0
  69. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_sse.py +0 -0
  70. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_start_and_poll.py +0 -0
  71. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_start_and_poll_asyncio.py +0 -0
  72. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_static_files_serving.py +0 -0
  73. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_templates.py +0 -0
  74. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_url_parameters.py +0 -0
  75. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/httpserver_websocket.py +0 -0
  76. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/examples/settings.toml +0 -0
  77. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/optional_requirements.txt +0 -0
  78. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/requirements.txt +0 -0
  79. {adafruit-circuitpython-httpserver-4.5.7 → adafruit_circuitpython_httpserver-4.5.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: adafruit-circuitpython-httpserver
3
- Version: 4.5.7
3
+ Version: 4.5.8
4
4
  Summary: Simple HTTP Server for CircuitPython
5
5
  Author-email: Adafruit Industries <circuitpython@adafruit.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: adafruit-circuitpython-httpserver
3
- Version: 4.5.7
3
+ Version: 4.5.8
4
4
  Summary: Simple HTTP Server for CircuitPython
5
5
  Author-email: Adafruit Industries <circuitpython@adafruit.com>
6
6
  License: MIT
@@ -42,6 +42,8 @@ docs/examples.rst.license
42
42
  docs/index.rst
43
43
  docs/index.rst.license
44
44
  docs/requirements.txt
45
+ docs/starting_methods.rst
46
+ docs/starting_methods.rst.license
45
47
  docs/_static/favicon.ico
46
48
  docs/_static/favicon.ico.license
47
49
  examples/directory_listing.tpl.html
@@ -52,7 +54,6 @@ examples/httpserver_chunked.py
52
54
  examples/httpserver_cookies.py
53
55
  examples/httpserver_cpu_information.py
54
56
  examples/httpserver_cpython.py
55
- examples/httpserver_ethernet_simpletest.py
56
57
  examples/httpserver_form_data.py
57
58
  examples/httpserver_handler_serves_file.py
58
59
  examples/httpserver_mdns.py
@@ -60,9 +61,11 @@ examples/httpserver_methods.py
60
61
  examples/httpserver_multiple_servers.py
61
62
  examples/httpserver_neopixel.py
62
63
  examples/httpserver_redirects.py
63
- examples/httpserver_simpletest_auto.py
64
- examples/httpserver_simpletest_connectionmanager.py
65
- examples/httpserver_simpletest_manual.py
64
+ examples/httpserver_simpletest_auto_connection_manager.py
65
+ examples/httpserver_simpletest_auto_settings_toml.py
66
+ examples/httpserver_simpletest_manual_ap.py
67
+ examples/httpserver_simpletest_manual_ethernet.py
68
+ examples/httpserver_simpletest_manual_wifi.py
66
69
  examples/httpserver_sse.py
67
70
  examples/httpserver_start_and_poll.py
68
71
  examples/httpserver_start_and_poll_asyncio.py
@@ -19,7 +19,7 @@ Implementation Notes
19
19
  https://github.com/adafruit/circuitpython/releases
20
20
  """
21
21
 
22
- __version__ = "4.5.7"
22
+ __version__ = "4.5.8"
23
23
  __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer.git"
24
24
 
25
25
 
@@ -1,50 +1,21 @@
1
- Simple Test
2
- -----------
1
+ .. note::
2
+ All examples in this document are using ``Server`` in ``debug`` mode.
3
+ This mode is useful for development, but it is not recommended to use it in production.
4
+ More about Debug mode at the end of Examples section.
3
5
 
4
- **All examples in this document are using** ``Server`` **in** ``debug`` **mode.**
5
- **This mode is useful for development, but it is not recommended to use it in production.**
6
- **More about Debug mode at the end of Examples section.**
6
+ Different ways of starting the server
7
+ -------------------------------------
7
8
 
8
- This is the minimal example of using the library with CircuitPython.
9
- This example is serving a simple static text message.
9
+ There are several ways to start the server on CircuitPython, mostly depending on the device you are using and
10
+ whether you have access to external network.
10
11
 
11
- It also manually connects to the WiFi network.
12
+ Functionally, all of them are the same, not features of the server are limited or disabled in any way.
12
13
 
13
- .. literalinclude:: ../examples/httpserver_simpletest_manual.py
14
- :caption: examples/httpserver_simpletest_manual.py
15
- :emphasize-lines: 12-17
16
- :linenos:
17
-
18
- It is also possible to use Ethernet instead of WiFi.
19
- The only difference in usage is related to configuring the ``socket_source`` differently.
20
-
21
- .. literalinclude:: ../examples/httpserver_ethernet_simpletest.py
22
- :caption: examples/httpserver_ethernet_simpletest.py
23
- :emphasize-lines: 13-23
24
- :linenos:
25
-
26
- Although there is nothing wrong with this approach, from the version 8.0.0 of CircuitPython,
27
- `it is possible to use the environment variables <https://docs.circuitpython.org/en/latest/docs/environment.html#circuitpython-behavior>`_
28
- defined in ``settings.toml`` file to store secrets and configure the WiFi network.
29
-
30
- By default the library uses ``0.0.0.0`` and port ``5000`` for the server, as port ``80`` is reserved for the CircuitPython Web Workflow.
31
- If you want to use port ``80`` , you need to set ``CIRCUITPY_WEB_API_PORT`` to any other port, and then set ``port`` parameter in ``Server`` constructor to ``80`` .
14
+ Below you can find examples of different ways to start the server:
32
15
 
33
- This is the same example as above, but it uses the ``settings.toml`` file to configure the WiFi network.
16
+ .. toctree::
34
17
 
35
- **From now on, all the examples will use the** ``settings.toml`` **file to configure the WiFi network.**
36
-
37
- .. literalinclude:: ../examples/settings.toml
38
- :caption: settings.toml
39
- :lines: 5-
40
- :linenos:
41
-
42
- Note that we still need to import ``socketpool`` and ``wifi`` modules.
43
-
44
- .. literalinclude:: ../examples/httpserver_simpletest_auto.py
45
- :caption: examples/httpserver_simpletest_auto.py
46
- :emphasize-lines: 11
47
- :linenos:
18
+ starting_methods
48
19
 
49
20
  CPython usage
50
21
  --------------------
@@ -210,7 +181,7 @@ You can find more information about the template syntax in the
210
181
 
211
182
  .. literalinclude:: ../examples/httpserver_templates.py
212
183
  :caption: examples/httpserver_templates.py
213
- :emphasize-lines: 12-15,49-55
184
+ :emphasize-lines: 12-15,51-59
214
185
  :linenos:
215
186
 
216
187
  Form data parsing
@@ -0,0 +1,82 @@
1
+
2
+ Manual WiFi
3
+ -----------
4
+
5
+ This is the minimal example of using the library with CircuitPython.
6
+ This example is serving a simple static text message.
7
+
8
+ It also manually connects to the WiFi network. SSID and password are stored in the code, but they
9
+ can as well be stored in the ``settings.toml`` file, and then read from there using ``os.getenv()``.
10
+
11
+ .. literalinclude:: ../examples/httpserver_simpletest_manual_wifi.py
12
+ :caption: examples/httpserver_simpletest_manual_wifi.py
13
+ :emphasize-lines: 10-17
14
+ :linenos:
15
+
16
+ Manual AP (access point)
17
+ ------------------------
18
+
19
+ If there is no external network available, it is possible to create an access point (AP) and run a server on it.
20
+ It is important to note that only devices connected to the AP will be able to access the server and depending on the device,
21
+ it may not be able to access the internet.
22
+
23
+ .. literalinclude:: ../examples/httpserver_simpletest_manual_ap.py
24
+ :caption: examples/httpserver_simpletest_manual_ap.py
25
+ :emphasize-lines: 11-16,30
26
+ :linenos:
27
+
28
+ Manual Ethernet
29
+ ---------------
30
+
31
+ Most of the time, the WiFi will be a preferred way of connecting to the network.
32
+ Nevertheless it is also possible to use Ethernet instead of WiFi.
33
+ The only difference in usage is related to configuring the ``socket_source`` differently.
34
+
35
+ .. literalinclude:: ../examples/httpserver_simpletest_manual_ethernet.py
36
+ :caption: examples/httpserver_simpletest_manual_ethernet.py
37
+ :emphasize-lines: 9-10,13-25,38
38
+ :linenos:
39
+
40
+ Automatic WiFi using ``settings.toml``
41
+ --------------------------------------
42
+
43
+ From the version 8.0.0 of CircuitPython,
44
+ `it is possible to use the environment variables <https://docs.circuitpython.org/en/latest/docs/environment.html#circuitpython-behavior>`_
45
+ defined in ``settings.toml`` file to store secrets and configure the WiFi network
46
+ using the ``CIRCUITPY_WIFI_SSID`` and ``CIRCUITPY_WIFI_PASSWORD`` variables.
47
+
48
+ By default the library uses ``0.0.0.0`` and port ``5000`` for the server, as port ``80`` is reserved for the CircuitPython Web Workflow.
49
+ If you want to use port ``80`` , you need to set ``CIRCUITPY_WEB_API_PORT`` to any other port, and then set ``port`` parameter in ``Server`` constructor to ``80`` .
50
+
51
+ This is the same example as above, but it uses the ``settings.toml`` file to configure the WiFi network.
52
+
53
+ .. note::
54
+ From now on, all the examples will use the ``settings.toml`` file to configure the WiFi network.
55
+
56
+ .. literalinclude:: ../examples/settings.toml
57
+ :caption: settings.toml
58
+ :lines: 5-
59
+ :linenos:
60
+
61
+ Note that we still need to import ``socketpool`` and ``wifi`` modules.
62
+
63
+ .. literalinclude:: ../examples/httpserver_simpletest_auto_settings_toml.py
64
+ :caption: examples/httpserver_simpletest_auto_settings_toml.py
65
+ :emphasize-lines: 11
66
+ :linenos:
67
+
68
+
69
+ Helper for socket pool using ``adafruit_connection_manager``
70
+ ------------------------------------------------------------
71
+
72
+ If you do not want to configure the socket pool manually, you can use the ``adafruit_connection_manager`` library,
73
+ which provides helpers for getting socker pool and SSL context for common boards.
74
+
75
+ Note that it is not installed by default.
76
+ You can read `more about the it here <https://docs.circuitpython.org/projects/connectionmanager/en/latest/index.html>`_.
77
+
78
+
79
+ .. literalinclude:: ../examples/httpserver_simpletest_auto_connection_manager.py
80
+ :caption: examples/httpserver_simpletest_auto_connection_manager.py
81
+ :emphasize-lines: 7,11
82
+ :linenos:
@@ -0,0 +1,3 @@
1
+ SPDX-FileCopyrightText: 2024 Michał Pokusa
2
+
3
+ SPDX-License-Identifier: MIT
@@ -0,0 +1,23 @@
1
+ # SPDX-FileCopyrightText: 2024 DJDevon3
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ import wifi
6
+
7
+ from adafruit_connection_manager import get_radio_socketpool
8
+ from adafruit_httpserver import Server, Request, Response
9
+
10
+
11
+ pool = get_radio_socketpool(wifi.radio)
12
+ server = Server(pool, "/static", debug=True)
13
+
14
+
15
+ @server.route("/")
16
+ def base(request: Request):
17
+ """
18
+ Serve a default static plain text message.
19
+ """
20
+ return Response(request, "Hello from the CircuitPython HTTP Server!")
21
+
22
+
23
+ server.serve_forever(str(wifi.radio.ipv4_address))
@@ -0,0 +1,30 @@
1
+ # SPDX-FileCopyrightText: 2024 Michał Pokusa
2
+ #
3
+ # SPDX-License-Identifier: Unlicense
4
+
5
+ import socketpool
6
+ import wifi
7
+
8
+ from adafruit_httpserver import Server, Request, Response
9
+
10
+
11
+ AP_SSID = "..."
12
+ AP_PASSWORD = "..."
13
+
14
+ print("Creating access point...")
15
+ wifi.radio.start_ap(ssid=AP_SSID, password=AP_PASSWORD)
16
+ print(f"Created access point {AP_SSID}")
17
+
18
+ pool = socketpool.SocketPool(wifi.radio)
19
+ server = Server(pool, "/static", debug=True)
20
+
21
+
22
+ @server.route("/")
23
+ def base(request: Request):
24
+ """
25
+ Serve a default static plain text message.
26
+ """
27
+ return Response(request, "Hello from the CircuitPython HTTP Server!")
28
+
29
+
30
+ server.serve_forever(str(wifi.radio.ipv4_address_ap))
@@ -1,19 +1,21 @@
1
1
  # SPDX-FileCopyrightText: 2023 Tim C for Adafruit Industries
2
+ #
2
3
  # SPDX-License-Identifier: MIT
3
4
 
4
5
  import board
5
6
  import digitalio
6
7
 
7
8
  from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K
8
- import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket
9
+ from adafruit_wiznet5k import adafruit_wiznet5k_socket as socket
9
10
  from adafruit_httpserver import Server, Request, Response
10
11
 
11
- print("Wiznet5k HTTPServer Test")
12
12
 
13
13
  # For Adafruit Ethernet FeatherWing
14
14
  cs = digitalio.DigitalInOut(board.D10)
15
+
15
16
  # For Particle Ethernet FeatherWing
16
17
  # cs = digitalio.DigitalInOut(board.D5)
18
+
17
19
  spi_bus = board.SPI()
18
20
 
19
21
  # Initialize ethernet interface with DHCP
@@ -22,7 +24,6 @@ eth = WIZNET5K(spi_bus, cs)
22
24
  # Set the interface on the socket source
23
25
  socket.set_interface(eth)
24
26
 
25
- # Initialize the server
26
27
  server = Server(socket, "/static", debug=True)
27
28
 
28
29
 
@@ -2,21 +2,20 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Unlicense
4
4
 
5
- import os
6
-
7
5
  import socketpool
8
6
  import wifi
9
7
 
10
8
  from adafruit_httpserver import Server, Request, Response
11
9
 
12
- ssid = os.getenv("WIFI_SSID")
13
- password = os.getenv("WIFI_PASSWORD")
10
+ WIFI_SSID = "..."
11
+ WIFI_PASSWORD = "..."
14
12
 
15
- print("Connecting to", ssid)
16
- wifi.radio.connect(ssid, password)
17
- print("Connected to", ssid)
13
+ print(f"Connecting to {WIFI_SSID}...")
14
+ wifi.radio.connect(WIFI_SSID, WIFI_PASSWORD)
15
+ print(f"Connected to {WIFI_SSID}")
18
16
 
19
17
  pool = socketpool.SocketPool(wifi.radio)
18
+
20
19
  server = Server(pool, "/static", debug=True)
21
20
 
22
21
 
@@ -12,7 +12,7 @@ requires = [
12
12
  [project]
13
13
  name = "adafruit-circuitpython-httpserver"
14
14
  description = "Simple HTTP Server for CircuitPython"
15
- version = "4.5.7"
15
+ version = "4.5.8"
16
16
  readme = "README.rst"
17
17
  authors = [
18
18
  {name = "Adafruit Industries", email = "circuitpython@adafruit.com"}
@@ -1,33 +0,0 @@
1
- # SPDX-FileCopyrightText: 2024 DJDevon3
2
- # SPDX-License-Identifier: MIT
3
- # Coded for Circuit Python 9.
4
- """HTTP Server Simpletest with Connection Manager"""
5
- # pylint: disable=import-error
6
-
7
- import os
8
-
9
- import adafruit_connection_manager
10
- import wifi
11
-
12
- from adafruit_httpserver import Server, Request, Response
13
-
14
- # Get WiFi details, ensure these are setup in settings.toml
15
- ssid = os.getenv("WIFI_SSID")
16
- password = os.getenv("WIFI_PASSWORD")
17
-
18
- print("Connecting to WiFi...")
19
- wifi.radio.connect(ssid, password)
20
- print("✅ Wifi!")
21
-
22
- # Initalize Wifi, Socket Pool, Request Session
23
- pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
24
- server = Server(pool, "/static", debug=True)
25
-
26
-
27
- @server.route("/")
28
- def base(request: Request):
29
- """Serve a default static plain text message"""
30
- return Response(request, "Hello from the CircuitPython HTTP Server!")
31
-
32
-
33
- server.serve_forever(str(wifi.radio.ipv4_address))