In the app - a user clicks a button that performs processing on a temporary file, before being downloaded. I want to then delete the processed file (not to be confused with the downloaded file)
Code summarized below.
Kind regards
Gus
from dash import Dash, dcc, html, Input, Output
import os
app = Dash(__name__, )
app.layout = html.Div([
html.Button(children='Submit', id='button_submit', n_clicks=0, style={'width':'10%'}, type='button'),
dcc.Download(id="downloaded_file")
])
@app.callback(
Output('downloaded_file', 'data'),
Input('button_submit', 'n_clicks'),
prevent_initial_call=True)
def update_output(n_clicks, youtube_link):
if n_clicks > 0:
# File processing occurs, and it is saved locally
PROCESSED_FILE_LOCATION = '/path/'
# User downloads the processed file
return dcc.send_file(PROCESSED_FILE_LOCATION)
# How may I delete the processed file located in PROCESSED_FILE_LOCATION
if __name__ == '__main__':
app.run_server(debug=True)