Currently, I have a static JS file which is returned to user on a specific api request. The code which handles this is as follow
@app.route('/js/<path:path>')
def send_js(path):
return send_from_directory('js', path)
However, What i want to do is modify the current JS file (add some user specific modifications) and then return it to the user. Being a Java developer, I would have first read the file, made the in-memory modification and write those bytes to response object.
However, while trying to google send_file
and send_from_directory
i couldn't find a way where i can provide content of the file?
How should i implement this in flask?