|
@@ -12,3 +12,15 @@ class CosmohomeView(viewsets.ViewSet):
|
|
def generate_xml(cls, request: Request, *args, **kwargs) -> HttpResponse:
|
|
def generate_xml(cls, request: Request, *args, **kwargs) -> HttpResponse:
|
|
final_xml = generate_xml_task()
|
|
final_xml = generate_xml_task()
|
|
return HttpResponse('ok')
|
|
return HttpResponse('ok')
|
|
|
|
+
|
|
|
|
+ @classmethod
|
|
|
|
+ @action(methods=['get'], detail=False, url_path='xml')
|
|
|
|
+ def xml(cls, request: Request, *args, **kwargs) -> HttpResponse:
|
|
|
|
+ file = "cosmohome_products.xml"
|
|
|
|
+ try:
|
|
|
|
+ with open(file, 'rb') as f:
|
|
|
|
+ return HttpResponse(f.read(), content_type='text/xml')
|
|
|
|
+ except OSError:
|
|
|
|
+ print(f"No available {file} file. Please generate one first.")
|
|
|
|
+ pass
|
|
|
|
+ return HttpResponse('No available xml file. Please generate one first.', status=404)
|