mirror of
https://github.com/encounter/decomp.me.git
synced 2026-03-30 11:06:27 -07:00
50a2b836b9
* Migrate from poetry/black to uv/ruff * fixes * path change * path pt 2 * ah * mkst tweaks (#1674) * mkst tweaks * tweaks++ * doh * tweak harder --------- Co-authored-by: Mark Street <22226349+mkst@users.noreply.github.com>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
from django.utils.decorators import method_decorator
|
|
from django.utils.timezone import now
|
|
from rest_framework.request import Request
|
|
from rest_framework.response import Response
|
|
from rest_framework.views import APIView
|
|
|
|
from coreapp import libraries
|
|
|
|
from ..decorators.django import condition
|
|
from ..decorators.cache import globally_cacheable
|
|
|
|
|
|
boot_time = now()
|
|
|
|
|
|
@method_decorator(
|
|
globally_cacheable(max_age=300, stale_while_revalidate=30), name="dispatch"
|
|
)
|
|
class LibraryDetail(APIView):
|
|
@staticmethod
|
|
def libraries_json(platform: str = "") -> list[dict[str, object]]:
|
|
return [
|
|
{
|
|
"name": lib.name,
|
|
"supported_versions": lib.supported_versions,
|
|
"platform": lib.platform,
|
|
}
|
|
for lib in libraries.available_libraries()
|
|
if platform == "" or lib.platform == platform
|
|
]
|
|
|
|
@condition(last_modified_func=lambda request: boot_time)
|
|
def head(self, request: Request) -> Response:
|
|
return Response()
|
|
|
|
@condition(last_modified_func=lambda request: boot_time)
|
|
def get(self, request: Request) -> Response:
|
|
platform = request.query_params.get("platform", "")
|
|
return Response(
|
|
{
|
|
"libraries": LibraryDetail.libraries_json(platform=platform),
|
|
}
|
|
)
|