Skip to content

Commit 6fb4b56

Browse files
committed
neaten up file list
1 parent dc5c18f commit 6fb4b56

File tree

4 files changed

+130
-672
lines changed

4 files changed

+130
-672
lines changed

gurgleapps_webserver.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -322,33 +322,45 @@ def generate_root_page_html(self, files_and_folders):
322322
<html>
323323
<head>
324324
<title>GurgleApps.com Webserver</title>
325-
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
325+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
326+
<link href="/styles.css" rel="stylesheet">
326327
</head>
327328
<body class="bg-gray-100">
328-
<div class="container mx-auto p-8">
329-
<h1 class="text-3xl font-bold mb-4">Welcome to GurgleApps.com Webserver</h1>
330-
<h2 class="text-2xl mb-2">File List:</h2>
329+
"""
330+
yield """
331+
<div class="relative flex min-h-screen flex-col justify-center overflow-hidden bg-gray-50 py-6 sm:py-12">
332+
<div class="relative bg-white px-6 pb-8 pt-10 shadow-xl ring-1 ring-gray-900/5 sm:mx-auto sm:max-w-lg sm:rounded-lg sm:px-10">
333+
<div class="mx-auto max-w-md">
334+
<img src="/img/logo.svg" class="h-12 w-auto" alt="GurgleApps.com">
335+
"""
336+
yield """
337+
<div class="divide-y divide-gray-300/50">
338+
<div class="space-y-6 py-8 text-base leading-7 text-gray-600">
339+
<h1 class="text-lg font-semibold">Welcome to GurgleApps.com Webserver</h1>
340+
<h12 class="text-base font-semibold">File List:</h2>
341+
<ul class="space-y-2 mt-3">
331342
"""
332343
folder_icon_svg = """
333-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="inline-block w-6 h-6">
334-
<path d="M4 4a2 2 0 00-2 2v8a2 2 0 002 2h12a2 2 0 002-2V8a2 2 0 00-2-2H9.586A2 2 0 018 6H4z" />
344+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6 fill-indigo-800">
345+
<path d="M19.5 21a3 3 0 003-3v-4.5a3 3 0 00-3-3h-15a3 3 0 00-3 3V18a3 3 0 003 3h15zM1.5 10.146V6a3 3 0 013-3h5.379a2.25 2.25 0 011.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 013 3v1.146A4.483 4.483 0 0019.5 9h-15a4.483 4.483 0 00-3 1.146z" />
335346
</svg>
336347
"""
337348
file_icon_svg = """
338-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="inline-block w-6 h-6">
339-
<path d="M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V7.414A2 2 0 0016.414 6L13 2.586A2 2 0 0011.414 2H6z" />
349+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6 fill-indigo-800">
350+
<path d="M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0016.5 9h-1.875a1.875 1.875 0 01-1.875-1.875V5.25A3.75 3.75 0 009 1.5H5.625z" />
351+
<path d="M12.971 1.816A5.23 5.23 0 0114.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 013.434 1.279 9.768 9.768 0 00-6.963-6.963z" />
340352
</svg>
341353
"""
342-
yield "<ul class='list-none'>"
343354
for file_or_folder in files_and_folders:
344355
icon = folder_icon_svg if file_or_folder['type'] == 'directory' else file_icon_svg
345-
yield f"<li class='my-2'><a href='/{file_or_folder['name']}' class='text-blue-600 hover:text-blue-800'>{icon} {file_or_folder['name']}</a></li>"
356+
yield f"<li class='border-t pt-1'><a href='/{file_or_folder['name']}' class='flex items-center font-semibold text-slate-800 hover:text-indigo-800'>{icon}<p class='ml-2'>{file_or_folder['name']}</p></a></li>"
346357
yield "</ul>"
347358
# Closing tags for the body and container div
348359
yield """
349-
</div>
350-
</body>
351-
</html>
360+
</div>
361+
<div class="pt-3 text-base font-semibold leading-7">
362+
<p class="text-gray-900">More information</p><p><a href="https://gurgleapps.com/learn/projects/micropython-web-server-control-raspberry-pi-pico-projects" class="text-indigo-500 hover:text-sky-600">Project Home &rarr;</a>
363+
</p></div></div></div></div></div></body></html>
352364
"""
353365

354366

response.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ async def send_file(self, file_path, status_code=200, content_type="text/html"):
2929
file_size = os.stat(file_path)[6]
3030
await self.send_headers(status_code, content_type, content_length=file_size)
3131

32-
chunk_size = 1024 # Adjust the chunk size as needed
32+
#chunk_size = 1024 # Adjust the chunk size as needed
33+
chunk_size = 512 # Adjust the chunk size as needed
3334
with open(file_path, "rb") as f:
3435
while True:
3536
chunk = f.read(chunk_size)

www/img/logo.svg

Lines changed: 102 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)