Skip to content

Commit

Permalink
[Fix] files: was serving an iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien committed Sep 13, 2024
1 parent 34821d1 commit f5e333a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/py/extra/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ async def SendResponse(
await loop.sock_sendall(client, SERVER_ERROR)
except Exception as e:
exception(e)

return res

@classmethod
Expand All @@ -287,6 +288,7 @@ async def Serve(
) -> None:
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
server.bind((options.host, options.port))
# The argument is the backlog of connections that will be accepted before
# they are refused.
Expand Down
42 changes: 24 additions & 18 deletions src/py/extra/services/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,33 @@ def renderDir(
)
breadcrumbs.append("/")
return request.respondHTML(
html(
H.html(
H.head(
H.meta(charset="utf-8"),
H.meta(
name="viewport",
content="width=device-width, initial-scale=1.0",
),
H.title(path),
H.style(FILE_CSS),
H.body(
H.h1(
"Listing for ",
H.a(f"{parent}/", href=f"/{parent}/") if parent else "",
current,
"".join(
html(
H.html(
H.head(
H.meta(charset="utf-8"),
H.meta(
name="viewport",
content="width=device-width, initial-scale=1.0",
),
H.title(path),
H.style(FILE_CSS),
H.body(
H.h1(
"Listing for ",
(
H.a(f"{parent}/", href=f"/{parent}/")
if parent
else ""
),
current,
),
*nodes,
),
*nodes,
),
),
),
doctype="html",
doctype="html",
)
)
)

Expand Down

0 comments on commit f5e333a

Please sign in to comment.