File tree Expand file tree Collapse file tree 3 files changed +47
-2
lines changed Expand file tree Collapse file tree 3 files changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ def mime_type(filename):
174
174
175
175
176
176
class HTTPResponse :
177
- """Details of an HTTP response. Use in @ `HTTPServer.route` decorator functions."""
177
+ """Details of an HTTP response. Use in `HTTPServer.route` decorator functions."""
178
178
179
179
_HEADERS_FORMAT = (
180
180
"HTTP/1.1 {}\r \n "
@@ -361,3 +361,25 @@ def poll(self):
361
361
# connection reset by peer, try again later.
362
362
return
363
363
raise
364
+
365
+ @property
366
+ def request_buffer_size (self ) -> int :
367
+ """
368
+ The maximum size of the incoming request buffer. If the default size isn't
369
+ adequate to handle your incoming data you can set this after creating the
370
+ server instance.
371
+
372
+ Default size is 1024 bytes.
373
+
374
+ Example::
375
+
376
+ server = HTTPServer(pool)
377
+ server.request_buffer_size = 2048
378
+
379
+ server.serve_forever(str(wifi.radio.ipv4_address))
380
+ """
381
+ return len (self ._buffer )
382
+
383
+ @request_buffer_size .setter
384
+ def request_buffer_size (self , value : int ) -> None :
385
+ self ._buffer = bytearray (value )
Original file line number Diff line number Diff line change @@ -6,3 +6,22 @@ Ensure your device works with this simple test.
6
6
.. literalinclude :: ../examples/httpserver_simpletest.py
7
7
:caption: examples/httpserver_simpletest.py
8
8
:linenos:
9
+
10
+ Temperature test
11
+ --------------------
12
+
13
+ Send the microcontroller temperature back to the browser with this simple test.
14
+
15
+ .. literalinclude :: ../examples/httpserver_temperature.py
16
+ :caption: examples/httpserver_temperature.py
17
+ :linenos:
18
+
19
+ Simple polling test
20
+ -------------------
21
+
22
+ If you want your code to do more than just serve web pages,
23
+ use the start/poll methods as shown in this example.
24
+
25
+ .. literalinclude :: ../examples/httpserver_simplepolling.py
26
+ :caption: examples/httpserver_simplepolling.py
27
+ :linenos:
Original file line number Diff line number Diff line change @@ -30,7 +30,11 @@ def base(request): # pylint: disable=unused-argument
30
30
31
31
while True :
32
32
try :
33
- # processing any waiting requests
33
+ # do something useful in this section,
34
+ # for example read a sensor and capture an average,
35
+ # or a running total of the last 10 samples
36
+
37
+ # process any waiting requests
34
38
server .poll ()
35
39
except OSError :
36
40
continue
You can’t perform that action at this time.
0 commit comments