diff --git a/ereuse_devicehub/resources/versions/versions.py b/ereuse_devicehub/resources/versions/versions.py index 516a08c6..9f29668a 100644 --- a/ereuse_devicehub/resources/versions/versions.py +++ b/ereuse_devicehub/resources/versions/versions.py @@ -1,10 +1,18 @@ import flask +import json import teal.marshmallow import ereuse_utils from typing import Callable, Iterable, Tuple from flask import make_response, g -from teal.resource import Resource +from teal.resource import Resource, View + + +class VersionView(View): + def get(self, *args, **kwargs): + """Get version.""" + v = "{}".format(ereuse_utils.version('ereuse-devicehub')) + return json.dumps({'devicehub': v}) class VersionDef(Resource): @@ -15,21 +23,19 @@ class VersionDef(Resource): def __init__(self, app, import_name=__name__, + static_folder='static', static_url_path=None, + template_folder='templates', url_prefix=None, subdomain=None, url_defaults=None, root_path=None, cli_commands: Iterable[Tuple[Callable, str or None]] = tuple()): - - super().__init__(app, import_name, static_url_path, + super().__init__(app, import_name, static_folder, static_url_path, template_folder, url_prefix, subdomain, url_defaults, root_path, cli_commands) - d = {'id': None} + + d = {'devicehub': '0.1.0a'} get = {'GET'} - self.add_url_rule('/', defaults=d, view_func=self.view, methods=get) - - def view(self): - #import pdb; pdb.set_trace() - v = "{}".format(ereuse_utils.version('ereuse-devicehub')) - return {'devicehub': v} + version_view = VersionView.as_view('stockDocumentView', definition=self) + self.add_url_rule('/', defaults=d, view_func=version_view, methods=get)