diff --git a/src/pyflask/app.py b/src/pyflask/app.py index 1cac80005..28b0f8a30 100644 --- a/src/pyflask/app.py +++ b/src/pyflask/app.py @@ -34,7 +34,6 @@ neurosift_namespace, startup_namespace, system_namespace, - time_namespace, ) neurosift_file_registry = collections.defaultdict(bool) @@ -66,7 +65,6 @@ api.add_namespace(data_namespace) api.add_namespace(system_namespace) api.add_namespace(dandi_namespace) -api.add_namespace(time_namespace) # api.add_namespace(neurosift_namespace) # TODO: enable later api.init_app(flask_app) diff --git a/src/pyflask/namespaces/__init__.py b/src/pyflask/namespaces/__init__.py index d3a085378..0f1edb274 100644 --- a/src/pyflask/namespaces/__init__.py +++ b/src/pyflask/namespaces/__init__.py @@ -4,4 +4,3 @@ from .neurosift import neurosift_namespace from .startup import startup_namespace from .system import system_namespace -from .time import time_namespace diff --git a/src/pyflask/namespaces/system.py b/src/pyflask/namespaces/system.py index 491cf36aa..1bdef06da 100644 --- a/src/pyflask/namespaces/system.py +++ b/src/pyflask/namespaces/system.py @@ -20,3 +20,26 @@ def get(self) -> Union[Dict[str, int], None]: logical = cpu_count() return dict(physical=physical, logical=logical) + +@system_namespace.route("/all_timezones") +class GetTimezones(flask_restx.Resource): + + @time_namespace.doc( + description="Request the available timezones available to the backend.", + ) + def get(self) -> List[str]: + import zoneinfo + + return list(zoneinfo.available_timezones()) + + +@system_namespace.route("/local_timezone") +class GetTimezones(flask_restx.Resource): + + @time_namespace.doc( + description="Request the current timezone on the system.", + ) + def get(self) -> str: + import tzlocal + + return tzlocal.get_localzone_name() \ No newline at end of file diff --git a/src/pyflask/namespaces/time.py b/src/pyflask/namespaces/time.py deleted file mode 100644 index 6602667b7..000000000 --- a/src/pyflask/namespaces/time.py +++ /dev/null @@ -1,31 +0,0 @@ -"""An API for handling general time information.""" - -from typing import Dict, Union - -import flask_restx - -time_namespace = flask_restx.Namespace(name="time", description="Request time-related information.") - - -@time_namespace.route("/timezones") -class GetTimezones(flask_restx.Resource): - - @time_namespace.doc( - description="Request the available timezones on the system.", - ) - def get(self) -> Union[Dict[str, int], None]: - from zoneinfo import available_timezones - - return list(available_timezones()) - - -@time_namespace.route("/timezone") -class GetTimezones(flask_restx.Resource): - - @time_namespace.doc( - description="Request the current timezone on the system.", - ) - def get(self) -> Union[Dict[str, int], None]: - from tzlocal import get_localzone - - return str(get_localzone())