1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-13 20:08:55 +00:00

Redirection to the bundled web-ui in the root handler

This commit is contained in:
grossmj 2020-05-06 16:31:18 +09:30
parent 0a77233631
commit 91a1c5db49
2 changed files with 5 additions and 11 deletions

View File

@ -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",

View File

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