From 92f58959be249c626f610cece8734d92d2b6380f Mon Sep 17 00:00:00 2001 From: James Pace Date: Sun, 1 Mar 2026 15:26:19 -0500 Subject: [PATCH] Host the UI. --- CMakeLists.txt | 8 +++++++- am_i_up/client.py | 8 ++++---- am_i_up/server.py | 10 +++++++--- launch/am_i_up.launch.xml | 3 +++ 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 launch/am_i_up.launch.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a9c56b..6de0467 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,14 @@ ament_python_install_package(${PROJECT_NAME}) install(DIRECTORY scripts/ - DESTINATION lib/${PROJECT_NAME}/lib + DESTINATION lib/${PROJECT_NAME}/ USE_SOURCE_PERMISSIONS ) +# Install launch files. +install(DIRECTORY + launch + DESTINATION share/${PROJECT_NAME}/ +) + ament_package() diff --git a/am_i_up/client.py b/am_i_up/client.py index 5fda2d4..ff34f01 100644 --- a/am_i_up/client.py +++ b/am_i_up/client.py @@ -42,26 +42,26 @@ async def call_ping(options): print("Calling ping with request: {}", json.dumps(request)) async with aiohttp.ClientSession() as session: - async with session.get('http://localhost:8080/api/ping', json=request) as resp: + async with session.get('http://localhost:8888/api/ping', json=request) as resp: print(await resp.text()) async def call_uptime(): print("Calling uptime.") async with aiohttp.ClientSession() as session: - async with session.get('http://localhost:8080/api/uptime') as resp: + async with session.get('http://localhost:8888/api/uptime') as resp: print(await resp.text()) async def call_build_info(): print("Calling build_info.") async with aiohttp.ClientSession() as session: - async with session.get('http://localhost:8080/api/build_info') as resp: + async with session.get('http://localhost:8888/api/build_info') as resp: print(await resp.text()) async def call_env(): print("Calling env.") async with aiohttp.ClientSession() as session: - async with session.get('http://localhost:8080/api/env') as resp: + async with session.get('http://localhost:8888/api/env') as resp: print(await resp.text()) diff --git a/am_i_up/server.py b/am_i_up/server.py index 907ea17..983930e 100644 --- a/am_i_up/server.py +++ b/am_i_up/server.py @@ -113,17 +113,21 @@ class Api: self._facts = facts async def run(self): + ui_share_directory = get_package_share_directory("am_i_up_ui") + ui_static_directory = ui_share_directory + "/dist" + app = web.Application() app.add_routes([ web.get('/api/ping', self.ping), web.get('/api/uptime', self.uptime), web.get('/api/build_info', self.build_info), web.get('/api/env', self.env), - web.get('/api/status', self.status) + web.get('/api/status', self.status), + web.static("/", ui_static_directory) ]) - url = "localhost" - port = 8080 + url = "0.0.0.0" + port = 8888 print("Listening on {}:{}".format(url, port)) runner = web.AppRunner(app) diff --git a/launch/am_i_up.launch.xml b/launch/am_i_up.launch.xml new file mode 100644 index 0000000..f4a4eed --- /dev/null +++ b/launch/am_i_up.launch.xml @@ -0,0 +1,3 @@ + + +