Host the UI.

This commit is contained in:
James Pace 2026-03-01 15:26:19 -05:00
parent 2f64b53543
commit 92f58959be
4 changed files with 21 additions and 8 deletions

View File

@ -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()

View File

@ -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())

View File

@ -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)

View File

@ -0,0 +1,3 @@
<launch>
<node pkg="am_i_up" exec="server" name="am_i_up"/>
</launch>