|
|
@@ -1,6 +1,8 @@
|
|
|
+import io
|
|
|
import json
|
|
|
import os
|
|
|
|
|
|
+from django.http import HttpResponse
|
|
|
from django.shortcuts import render
|
|
|
|
|
|
from rest_framework.response import Response
|
|
|
@@ -537,6 +539,22 @@ class QxzDeviceListView(GenericAPIView):
|
|
|
return self.get_paginated_response(serializer.data)
|
|
|
|
|
|
|
|
|
+class QxzConfigDownView(APIView):
|
|
|
+ def get(self, request, device_id, file_name, *args, **kwargs):
|
|
|
+ file_path = f"/data/qxz/element/config/{device_id}/{file_name}"
|
|
|
+ if os.path.exists(file_path):
|
|
|
+ with open(file_path, 'rb') as fr:
|
|
|
+ content = fr.read()
|
|
|
+ else:
|
|
|
+ file_name = "null.c"
|
|
|
+ content = b''
|
|
|
+
|
|
|
+ response = HttpResponse(content, content_type="application/octet-stream")
|
|
|
+ response['Content-Disposition'] = f'attachment; filename={file_name}'
|
|
|
+ response['Access-Control-Allow-Origin'] = "*"
|
|
|
+ return response
|
|
|
+
|
|
|
+
|
|
|
|
|
|
def init_data():
|
|
|
data = {
|