This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/resources/licences/licences.py

59 lines
1.4 KiB
Python
Raw Normal View History

2020-12-29 16:37:13 +00:00
from typing import Callable, Iterable, Tuple
2023-03-21 11:08:13 +00:00
2020-12-29 16:37:13 +00:00
from flask.json import jsonify
2023-03-21 11:08:13 +00:00
from ereuse_devicehub.teal.resource import Resource, View
2020-12-29 16:37:13 +00:00
class LicenceView(View):
def get(self, *args, **kwargs):
"""Get version of DeviceHub and ereuse-tag."""
2020-12-29 20:14:07 +00:00
app = self.resource_def.app
path_licences = app.config['LICENCES']
with open(path_licences) as f:
2020-12-29 16:37:13 +00:00
licences = f.read()
ret = jsonify(licences)
ret.status_code = 200
return ret
class LicencesDef(Resource):
__type__ = 'Licence'
SCHEMA = None
VIEW = None # We do not want to create default / documents endpoint
AUTH = False
2023-03-21 11:08:13 +00:00
def __init__(
self,
app,
import_name=__name__,
static_folder=None,
static_url_path=None,
template_folder=None,
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_folder,
static_url_path,
template_folder,
url_prefix,
subdomain,
url_defaults,
root_path,
cli_commands,
)
2020-12-29 16:37:13 +00:00
get = {'GET'}
d = {}
licence_view = LicenceView.as_view('LicenceView', definition=self)
self.add_url_rule('/', defaults=d, view_func=licence_view, methods=get)