diff --git a/gns3server/handlers/__init__.py b/gns3server/handlers/__init__.py index cd99ee1d..8c7f08b9 100644 --- a/gns3server/handlers/__init__.py +++ b/gns3server/handlers/__init__.py @@ -28,21 +28,7 @@ from gns3server.handlers.api.vpcs_handler import VPCSHandler from gns3server.handlers.api.config_handler import ConfigHandler from gns3server.handlers.api.server_handler import ServerHandler from gns3server.handlers.upload_handler import UploadHandler -from ..web.route import Route - -if sys.platform.startswith("linux") or hasattr(sys, "_called_from_test"): - from gns3server.handlers.api.iou_handler import IOUHandler - -class HomePage: - - @classmethod - @Route.get( - r"/", - description="Home page for GNS3Server", - api_version=None - ) - def index(request, response): - response.template("homepage.html") +from gns3server.handlers.index_handler import IndexHandler if sys.platform.startswith("linux") or hasattr(sys, "_called_from_test"): from gns3server.handlers.api.iou_handler import IOUHandler diff --git a/gns3server/handlers/index_handler.py b/gns3server/handlers/index_handler.py new file mode 100644 index 00000000..1ed5d696 --- /dev/null +++ b/gns3server/handlers/index_handler.py @@ -0,0 +1,27 @@ +# +# Copyright (C) 2015 GNS3 Technologies Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from ..web.route import Route + +class IndexHandler: + @classmethod + @Route.get( + r"/", + description="Home page for GNS3Server", + api_version=None + ) + def index(request, response): + response.template("index.html") diff --git a/gns3server/templates/homepage.html b/gns3server/templates/homepage.html deleted file mode 100644 index 3297c2b5..00000000 --- a/gns3server/templates/homepage.html +++ /dev/null @@ -1,18 +0,0 @@ - - - -GNS3 Server - - -{% block body %}{% endblock %} - -

- Welcome to Home page of GNS3. -

-

- Visit the upload page to try GNS3 features: Upload -

- - Powered by GNS3 {{gns3_version}} - - diff --git a/gns3server/templates/index.html b/gns3server/templates/index.html new file mode 100644 index 00000000..f0fa4304 --- /dev/null +++ b/gns3server/templates/index.html @@ -0,0 +1,11 @@ +{% extends "layout.html" %} +{% block body %} +

+ Welcome to GNS 3. +

+ +{% endblock %} diff --git a/tests/handlers/test_index.py b/tests/handlers/test_index.py new file mode 100644 index 00000000..1fc19243 --- /dev/null +++ b/tests/handlers/test_index.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2015 GNS3 Technologies Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +import aiohttp +import os +from unittest.mock import patch + +from gns3server.version import __version__ + + +def test_index(server): + response = server.get('/', api_version=None) + assert response.status == 200 + html = response.html + assert "Community" in html + assert __version__ in html diff --git a/tests/handlers/test_upload.py b/tests/handlers/test_upload.py index 4e3cebc5..63d60ef8 100644 --- a/tests/handlers/test_upload.py +++ b/tests/handlers/test_upload.py @@ -20,8 +20,6 @@ import aiohttp import os from unittest.mock import patch -from gns3server.version import __version__ - def test_index_upload(server): response = server.get('/upload', api_version=None)