Skip to content
This repository was archived by the owner on Jun 7, 2021. It is now read-only.

Commit 11cf50b

Browse files
committed
Updated some comments
1 parent 8930ea9 commit 11cf50b

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

example/mjpeg-stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def stream_generator(self):
8282
await self.event.wait()
8383
# Get the current frame
8484
img = self.stream.getvalue()
85-
# Write the frame data to the Tornado client
85+
# Add frame header data
8686
served_image_timestamp = time.time()
8787
prefix = (
8888
my_boundary

webthing/server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ async def represent_response(
6868

6969
self.set_header("Content-Type", content_type)
7070

71+
# If the response data is a generator, handle it specially
7172
if isinstance(data, (typing.AsyncGenerator, types.GeneratorType)):
7273
self.set_header(
7374
"Cache-Control",
@@ -87,9 +88,12 @@ async def represent_response(
8788
self.write(frame)
8889
# Write data to network
8990
await self.flush()
91+
# If the response data is not a generator
9092
else:
93+
# If the response contentType is JSON, format data first
9194
if content_type == "application/json":
9295
data = json.dumps(data)
96+
# Write data
9397
self.write(data)
9498

9599

0 commit comments

Comments
 (0)