mirror of
https://github.com/Eugeny/tabby-web.git
synced 2026-08-17 06:46:05 +01:00
fixup
This commit is contained in:
@@ -81,6 +81,7 @@ class AppVersionViewSet(ListModelMixin, GenericViewSet):
|
||||
return [
|
||||
self._get_version(x['name'])
|
||||
for x in fs.listdir(settings.APP_DIST_STORAGE)
|
||||
if x['type'] == 'directory'
|
||||
]
|
||||
|
||||
def _get_version(self, dir):
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import fsspec
|
||||
import os
|
||||
from fsspec.implementations.local import LocalFileSystem
|
||||
from django.conf import settings
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.http.response import FileResponse, HttpResponseNotFound, HttpResponseRedirect
|
||||
from django.views import static
|
||||
from rest_framework.views import APIView
|
||||
from urllib.parse import urlparse
|
||||
@@ -24,4 +26,9 @@ class AppDistView(APIView):
|
||||
def get(self, request, version=None, path=None, format=None):
|
||||
fs = fsspec.filesystem(urlparse(settings.APP_DIST_STORAGE).scheme)
|
||||
url = f'{settings.APP_DIST_STORAGE}/{version}/{path}'
|
||||
return HttpResponseRedirect(fs.url(url))
|
||||
if isinstance(fs, LocalFileSystem):
|
||||
if not fs.exists(url):
|
||||
return HttpResponseNotFound()
|
||||
return FileResponse(fs.open(url), filename=os.path.basename(url))
|
||||
else:
|
||||
return HttpResponseRedirect(fs.url(url))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.urls import path, include
|
||||
from django.views.static import serve
|
||||
from .app.urls import urlpatterns as app_urlpatterns
|
||||
@@ -8,7 +9,7 @@ urlpatterns = [
|
||||
path('', include(app_urlpatterns)),
|
||||
path('api/1/auth/social/', include('social_django.urls', namespace='social')),
|
||||
path('admin/', admin.site.urls),
|
||||
path(f'{settings.STATIC_URL.strip("/")}/<path:path>', serve, kwargs={
|
||||
'document_root': settings.STATIC_ROOT,
|
||||
}),
|
||||
]
|
||||
# path(f'{settings.STATIC_URL.strip("/")}/<path:path>', serve, kwargs={
|
||||
# 'document_root': settings.STATIC_ROOT,
|
||||
# }),
|
||||
] + staticfiles_urlpatterns(settings.STATIC_URL)
|
||||
|
||||
Reference in New Issue
Block a user