예제 #1
0
 def qr_code(self, request):
     qrcode = QRCode.get_or_create(
         poim_client=self.poim_client,
         session_id=session_id,
     )
     qrcode.save()
     fp = mk_qrcode(qrcode.url)
     return ResponseStream(fp)
예제 #2
0
def csv_download_response(rows, filename, fieldnames=None):
    response = Response(
        content_type='text/csv',
        headers={
            'Content-disposition': f'attachment; filename="{filename}"',
        },
    )
    csv_writer = csv.DictWriter(ResponseStream(response),
                                fieldnames=fieldnames)
    csv_writer.writeheader()
    csv_writer.writerows(rows)
    return response
예제 #3
0
def response_with_csv_download(rows, filename_prefix, fieldnames=None):
    now = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
    response = Response(
        content_type='text/csv',
        headers={
            'Content-disposition':
            f'attachment; filename="{filename_prefix}_{now}.csv"',
        },
    )
    csv_writer = csv.DictWriter(ResponseStream(response),
                                fieldnames=fieldnames)
    csv_writer.writeheader()
    csv_writer.writerows(rows)
    return response
예제 #4
0
 def out_stream(self):
     """The response iterable as write-only stream."""
     return ResponseStream(self)