Skip to content

Commit 6df991b

Browse files
authored
Merge pull request #51 from jrrickerson/add_simpletest_example
Add a bare minimum simpletest example
2 parents 0850aba + 6e1926a commit 6df991b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

docs/examples.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Simple file serving
1+
Simple Test
22
-------------------
33

4-
Serving the content of index.html from the filesystem.
4+
Serving a simple static text message.
55

6-
.. literalinclude:: ../examples/httpserver_simple_serve.py
7-
:caption: examples/httpserver_simple_serve.py
6+
.. literalinclude:: ../examples/httpserver_simpletest.py
7+
:caption: examples/httpserver_simpletest.py
88
:linenos:
99

1010
If you want your code to do more than just serve web pages,

examples/httpserver_simple_serve.py renamed to examples/httpserver_simpletest.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
@server.route("/")
2828
def base(request: HTTPRequest):
2929
"""
30-
Serve the default index.html file.
30+
Serve a default static plain text message.
3131
"""
32-
with HTTPResponse(request, content_type=MIMEType.TYPE_HTML) as response:
33-
response.send_file("index.html")
32+
with HTTPResponse(request, content_type=MIMEType.TYPE_TXT) as response:
33+
message = "Hello from the CircuitPython HTTPServer!"
34+
response.send(message)
3435

3536

3637
print(f"Listening on http://{wifi.radio.ipv4_address}:80")

0 commit comments

Comments
 (0)