Play nice with react router.
This commit is contained in:
parent
92f58959be
commit
85ed0af7e4
|
|
@ -114,7 +114,7 @@ class Api:
|
|||
|
||||
async def run(self):
|
||||
ui_share_directory = get_package_share_directory("am_i_up_ui")
|
||||
ui_static_directory = ui_share_directory + "/dist"
|
||||
ui_static_directory = ui_share_directory + "/dist/assets"
|
||||
|
||||
app = web.Application()
|
||||
app.add_routes([
|
||||
|
|
@ -123,7 +123,10 @@ class Api:
|
|||
web.get('/api/build_info', self.build_info),
|
||||
web.get('/api/env', self.env),
|
||||
web.get('/api/status', self.status),
|
||||
web.static("/", ui_static_directory)
|
||||
web.static("/assets", ui_static_directory),
|
||||
# we're not actually using key anywhere, but doing this allows react router
|
||||
# to work correctly.
|
||||
web.get("/{key:.*}", self.index)
|
||||
])
|
||||
|
||||
url = "0.0.0.0"
|
||||
|
|
@ -139,6 +142,11 @@ class Api:
|
|||
await asyncio.sleep(3600)
|
||||
await runner.cleanup()
|
||||
|
||||
async def index(self, request):
|
||||
ui_share_directory = get_package_share_directory("am_i_up_ui")
|
||||
ui_index_path = ui_share_directory + "/dist/index.html"
|
||||
return web.FileResponse(ui_index_path)
|
||||
|
||||
async def ping(self, request):
|
||||
request_dict = await request.json()
|
||||
result = self._facts.do_ping(request_dict['address'])
|
||||
|
|
|
|||
Loading…
Reference in New Issue