From 91a1c5db497617d8243d47eda67a295eb49a7d14 Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 6 May 2020 16:31:18 +0930 Subject: [PATCH] Redirection to the bundled web-ui in the root handler --- gns3server/handlers/index_handler.py | 12 +----------- gns3server/web/route.py | 4 ++++ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/gns3server/handlers/index_handler.py b/gns3server/handlers/index_handler.py index 3ae3d23f..12c4c5ba 100644 --- a/gns3server/handlers/index_handler.py +++ b/gns3server/handlers/index_handler.py @@ -33,17 +33,7 @@ class IndexHandler: ) async def index(request, response): - #FIXME: this could probably be handled in a better way - static = get_resource(os.path.join('static', 'web-ui', 'index.html')) - print(static) - - # guesstype prefers to have text/html type than application/javascript - # which results with warnings in Firefox 66 on Windows - # Ref. gns3-server#1559 - _, ext = os.path.splitext(static) - mimetype = ext == '.js' and 'application/javascript' or None - - await response.stream_file(static, status=200, set_content_type=mimetype) + raise aiohttp.web.HTTPFound(location="/static/web-ui/bundled") @Route.get( r"/debug", diff --git a/gns3server/web/route.py b/gns3server/web/route.py index 59fb5f8e..d1275250 100644 --- a/gns3server/web/route.py +++ b/gns3server/web/route.py @@ -200,6 +200,10 @@ class Route(object): response = Response(request=request, route=route) response.set_status(e.status) response.json({"message": e.text, "status": e.status, "path": route, "request": request.json, "method": request.method}) + except aiohttp.web.HTTPFound as e: + response = Response(request=request, route=route) + response.set_status(e.status) + raise # must raise to let aiohttp know about the redirection except aiohttp.web.HTTPException as e: response = Response(request=request, route=route) response.set_status(e.status)