parameters: (request, project_id, volume_id, extension)
docstring: Export volume as a triangle mesh file.
  
      The extension of the endpoint and `ACCEPT` header media type are both used
      to determine the format of the export.
  
      Supported formats by extension and media type:
      ##### STL
        - `model/stl`, `model/x.stl-ascii`: ASCII STL
docstring_summary: Export volume as a triangle mesh file.
docstring_tokens: Export volume as a triangle mesh file .
function: def export_volume(request, project_id, volume_id, extension) -> HttpResponse:
      """Export volume as a triangle mesh file.
  
      The extension of the endpoint and `ACCEPT` header media type are both used
      to determine the format of the export.
  
      Supported formats by extension and media type:
      ##### STL
        - `model/stl`, `model/x.stl-ascii`: ASCII STL
  
      """
      acceptable = {
          'stl': ['model/stl', 'model/x.stl-ascii'],
      }
      if extension.lower() in acceptable:
          media_types = request.META.get('HTTP_ACCEPT', '').split(',')
          for media_type in media_types:
              if media_type in acceptable[extension]:
                  details = get_volume_details(project_id, volume_id)
                  ascii_details = _x3d_to_stl_ascii(details['mesh'])
                  response = HttpResponse(content_type=media_type)
                  response.write(ascii_details)
                  return response
          return HttpResponse('Media types "{}" not understood. Known types for {}: {}'.format(
              ', '.join(media_types), extension, ', '.join(acceptable[extension])), status=415)
      else:
          return HttpResponse('File type "{}" not understood. Known file types: {}'.format(
              extension, ', '.join(chain.from_iterable(acceptable.values()))), status=415)
function_tokens: def export_volume ( request , project_id , volume_id , extension ) -> HttpResponse : acceptable = { 'stl' : [ 'model/stl' , 'model/x.stl-ascii' ] , } if extension . lower ( ) in acceptable : media_types = request . META . get ( 'HTTP_ACCEPT' , '' ) . split ( ',' ) for media_type in media_types : if media_type in acceptable [ extension ] : details = get_volume_details ( project_id , volume_id ) ascii_details = _x3d_to_stl_ascii ( details [ 'mesh' ] ) response = HttpResponse ( content_type = media_type ) response . write ( ascii_details ) return response return HttpResponse ( 'Media types "{}" not understood. Known types for {}: {}' . format ( ', ' . join ( media_types ) , extension , ', ' . join ( acceptable [ extension ] ) ) , status = 415 ) else : return HttpResponse ( 'File type "{}" not understood. Known file types: {}' . format ( extension , ', ' . join ( chain . from_iterable ( acceptable . values ( ) ) ) ) , status = 415 )