后端代理mapConfig文件

This commit is contained in:
曹前明 2022-06-28 13:02:19 +08:00
parent 396a26ab15
commit 91218602e2
2 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import os
import cv2
from django.http import HttpResponse
from apps.utils.errors import SIGN_MAKE_FAIL
from server.settings import BASE_DIR
import numpy as np
@ -9,6 +10,7 @@ from rest_framework.exceptions import ParseError
from apps.utils.viewsets import CustomGenericViewSet
from apps.utils.mixins import CustomCreateModelMixin
from apps.utils.serializers import GenSignatureSerializer
from rest_framework.views import APIView
class SignatureViewSet(CustomCreateModelMixin, CustomGenericViewSet):
@ -48,3 +50,9 @@ class SignatureViewSet(CustomCreateModelMixin, CustomGenericViewSet):
return Response({'path': new_path.replace(BASE_DIR, '')})
except Exception:
raise ParseError(**SIGN_MAKE_FAIL)
def map_config(request):
path = os.path.join(BASE_DIR, 'dist/data/map/0000/mapConfig.conf')
with open(path) as f:
return HttpResponse(f.read(), content_type='application/octet-stream')

View File

@ -21,6 +21,7 @@ from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework.documentation import include_docs_urls
from django.views.generic import TemplateView
from apps.utils.views import map_config
schema_view = get_schema_view(
openapi.Info(
@ -60,7 +61,7 @@ urlpatterns = [
path('api/docs/', include_docs_urls(title="接口文档", authentication_classes=[], permission_classes=[])),
path('api/swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('api/redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
path('data/map/0000/mapConfig.conf', map_config),
# 前端页面入口
path('', TemplateView.as_view(template_name="index.html")),
] + \