So far, I am able to create an upload page where the user could upload a file. Now I want to store the contents of the file and I want to read the contents of the program, process the contents.
How can I do it? I am stuck at this point; please help. Here is what I have tried so far
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import dash_table
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
# colors = {
# 'background': '#000000',
# 'color': '#ffffff'
# }
file_upload_style={
'width': '99%',
'height': '60px',
'lineHeight': '60px',
'borderWidth': '2px',
'borderRadius': '1x',
'textAlign': 'center',
'margin': '10px'
}
header_style={
'textAlign' : 'center'
}
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Calculate per gene coverage',style=header_style),
dcc.Upload(
id='upload-data',
children=html.H4([
'Drag and Drop or ',
html.A('Select Files')
]),
style=file_upload_style,
# Dont' allow multiple files to be uploaded
multiple=False
),
html.Div(id='output-data-upload'),
])
@app.callback(dash.dependencies.Output('output-data-upload', 'children'),
[dash.dependencies.Input('upload-data', 'contents'),
dash.dependencies.Input('upload-data', 'filename')])
def update_output(contents, filename):
if contents is not None:
children='You have uploaded: ' + filename
return contents
else:
return 'Upload your file'
if __name__ == '__main__':
app.run_server(debug=True)