Closed wwwillchen closed 1 month ago
For this, I'm wondering if we can optionally allow the user to register a download route and let the user implement some function to handle downloads.
For the simple case, we could wrap the Flask send_from_directory
for Mesop usage. The issue here is that this function isn't great since it uses the local file system, so not really scalable, but could work basic uses cases. Another potential issue is people accessing other people's data. We could mitigate this a bit if we generated session IDs for users using the builtin Flask session object.
@app.route('/uploads/<path:filename>', methods=['GET', 'POST'])
def download(filename):
return send_from_directory(directory=app.config['UPLOAD_FOLDER'], filename=filename)
This also goes back to the question of whether want to expose more of the Flask internals or not. Though I lean toward not exposing more internals since I do think we'll likely want to move away from Flask at some point.
Interface maybe something like:
me.register_downloads_route(route_function)
I guess I'm not sure if the Mesop state would be possible to make state accessible from the route function since there could be cases where we just want to serialize data from state for download. Also it seems maybe a bit too specific to register a route specifically for downloads.
Hi All,
I'm interested in this functionality as well.
Looking forward to more comments on the topic!
@kevinknights29 just posted a response to: https://github.com/google/mesop/discussions/453#discussioncomment-10492369 - please take a look and let us know if you have any questions or comments.
Discussed in https://github.com/google/mesop/discussions/453