Exemple #1
0
 def get(self, ext):
     cube = get_cube()
     data, hdr = get_data(cube, ext.upper(), header=True)
     results = {'stream': cube, 'header': hdr.tostring(), 'data': data}
     return Response(orjson.dumps(results,
                                  option=orjson.OPT_SERIALIZE_NUMPY),
                     mimetype='application/json')
Exemple #2
0
async def fits_ext(ext: str):
    cube = get_cube()
    data, hdr = get_data(cube, ext.upper(), header=True)
    results = {'stream': cube, 'header': hdr.tostring(), 'data': data}
    # this is temporary until fastapi.responses.ORJSONResponse can accept options
    #return ORJSONResponseCustom(results, option=orjson.OPT_SERIALIZE_NUMPY)
    return Response(orjson.dumps(results, option=orjson.OPT_SERIALIZE_NUMPY),
                    media_type='application/json')
Exemple #3
0
def streaming_response():
    ''' stream a file-like object as a response '''
    cube = get_cube()
    file_like = open(cube, mode="rb")
    return StreamingResponse(file_like, media_type='application/octet-stream')
Exemple #4
0
async def file_response():
    ''' async streams a file as a response '''
    cube = get_cube()
    name = get_path('mangacube', full=cube, ptype='name')
    # fileresponse is used for streaming downloads
    return FileResponse(cube, filename=name, media_type='application/gzip')
Exemple #5
0
async def async_header():
    cube = get_cube()
    hdr = get_header(cube)
    results = {'stream': cube, 'header': hdr.tostring()}
    return results
Exemple #6
0
async def download_file():
    cube = get_cube()
    return await send_file(cube, as_attachment=True)
Exemple #7
0
async def json(ext):
    cube = get_cube()
    data, hdr = get_data(cube, ext=ext.upper(), header=True)
    results = {'stream': cube, 'header': hdr.tostring(), 'data': data}
    compressed = await compdata(results)
    return Response(compressed, mimetype='application/json')
Exemple #8
0
 def get(self):
     cube = get_cube()
     return send_file(cube, as_attachment=True)
Exemple #9
0
 def get(self):
     cube = get_cube()
     hdr = get_header(cube)
     results = {'stream': cube, 'header': hdr.tostring()}
     return results