Added Map capabilities

This commit is contained in:
Pablo Revilla
2025-02-20 09:02:51 -08:00
parent 1432cefb4b
commit 6ea5cf7eba
3 changed files with 23 additions and 4 deletions
+2
View File
@@ -19,6 +19,8 @@ git clone --recurse-submodules https://github.com/pablorevilla-meshtastic/meshvi
Create a python virtual environment:
``` bash
cd meshview
```
``` bash
python3 -m venv env
```
Install the environment requirements:
+1 -1
View File
@@ -36,7 +36,7 @@
<br><div style="text-align:center"><strong>Bay Area Mesh - http://bayme.sh</strong></div>
<div style="text-align:center">Quick Links:&nbsp;&nbsp;<a href="/nodelist">Nodes</a>&nbsp;-&nbsp;<a href="/chat">Conversations</a>&nbsp;-&nbsp;<a href="/firehose">See <strong>everything</strong> </a>
&nbsp;-&nbsp;Mesh Graph <a href="/graph/longfast">LF</a>&nbsp;-&nbsp;<a href="/graph/mediumslow">MS </a>&nbsp;-&nbsp;<a href="/stats">Stats </a>
&nbsp;-&nbsp;<a href="/net">Weekly Net</a></div><br>
&nbsp;-&nbsp;<a href="/net">Weekly Net</a>&nbsp;-&nbsp;<a href="/map">Map</a></div><br>
<div id="spinner" class="spinner-border secondary-primary htmx-indicator position-absolute top-50 start-50" role="status">
<span class="visually-hidden">Loading...</span>
</div>
+20 -3
View File
@@ -344,7 +344,7 @@ async def chat_events(request):
)
except ConnectionResetError:
# Log when a client disconnects unexpectedly
logging.warning("Client disconnected from SSE stream.")
print("Client disconnected from SSE stream.")
return # Exit the loop and close the connection
@@ -439,7 +439,7 @@ async def events(request):
)
except ConnectionResetError:
logging.warning("Client disconnected from SSE stream.")
print("Client disconnected from SSE stream.")
return # Gracefully exit on disconnection
@dataclass
@@ -1573,7 +1573,7 @@ async def net(request):
raise # Let aiohttp handle HTTP exceptions properly
except Exception as e:
logging.exception("Error processing chat request")
print("Error processing chat request")
return web.Response(
text="An internal server error occurred.",
status=500,
@@ -1617,6 +1617,23 @@ async def net_events(request):
return # Gracefully exit on disconnection
@routes.get("/map")
async def map(request):
try:
nodes= await store.get_nodes()
template = env.get_template("map.html")
return web.Response(
text=template.render(nodes=nodes),
content_type="text/html",
)
except Exception as e:
return web.Response(
text="An error occurred while processing your request.",
status=500,
content_type="text/plain",
)
async def run_server(bind, port, tls_cert):
app = web.Application()
app.add_routes(routes)