I wrote an application that handles uri on the client (angular router).
To serve webapp, I used a slightly different factory:
def index_factory(path,filename): async def static_view(request): # prefix not needed route = web.StaticRoute(None, '/', path) request.match_info['filename'] = filename return await route.handle(request) return static_view # json-api app.router.add_route({'POST','GET'}, '/api/{collection}', api_handler) # other static app.router.add_static('/static/', path='../static/', name='static') # index, loaded for all application uls. app.router.add_get('/{path:.*}', index_factory("../static/ht_docs/","index.html"))
source share