Closed jayceslesar closed 2 months ago
This allows us to display the size in the list_demos endpoint as well as change the demodata endpoint to include the size of the demo to get a progress bar
@get("/demodata", guards=[valid_key_guard, session_closed_guard, analyst_guard], sync_to_thread=False) def demodata(request: Request, api_key: str, session_id: str) -> Stream: """Return the demo.""" engine = request.app.state.engine bytestream_generator = demodata_helper(engine, api_key, session_id) file_size = os.path.getsize(session_id + ".dem") # Calculate the size of the file headers = { "Content-Disposition": f'attachment; filename="{session_id}.dem"', "Content-Length": str(file_size) # Include Content-Length header } return Stream(bytestream_generator, media_type=MediaType.TEXT, headers=headers)
To totally solve this issue:
58fb39990d30_initialize.py
_close_session_with_demo
os.stat
This allows us to display the size in the list_demos endpoint as well as change the demodata endpoint to include the size of the demo to get a progress bar
To totally solve this issue:
58fb39990d30_initialize.py
file to include demo_length as an integer_close_session_with_demo
function usingos.stat
os.stat