Skip to content
Snippets Groups Projects
Select Git revision
  • f4c8e1062bd26352c3a66f086d47b25b221593be
  • develop default protected
  • master protected
  • 1.17
  • 1.14.1
  • 1.16.0
  • 1.16
  • 1.15.1
  • 1.15.0
  • 1.15
  • 1.14
  • 1.13
  • 1.12
  • 1.11
  • 1.10
  • 1.9
  • Lime-Seal
  • 1.8
  • 1.7
  • 1.6
  • 1.5
  • 1.4
  • 1.3
23 results

default.py

Blame
  • default.py 855 B
    """Default route located at the root URL /.
    
    For now only includes a single endpoint that responds with the current version of the API and LSO.
    """
    
    from importlib import metadata
    
    from fastapi import APIRouter
    from pydantic import BaseModel, constr
    
    API_VERSION = "0.1"
    VersionString = constr(pattern=r"\d+\.\d+")
    
    router = APIRouter()
    
    
    class Version(BaseModel):
        """Simple model for returning a version number of both the API and the `goat-lso` module."""
    
        api: VersionString  # type: ignore[valid-type]
        module: VersionString  # type: ignore[valid-type]
    
    
    @router.get("/version")
    def version() -> Version:
        """Return the version numbers of the API version, and the module version.
    
        :return: Version object with both API and `goat-lso` versions numbers.
        """
        return Version(api=API_VERSION, module=metadata.version("goat-lso"))