Pass file information from html file selector input to python and bokeh
<p>I'm trying to create a simple bokeh server application that allows a user to load a file from a <code>&lt;input type="file"&gt;</code> file selection button. The app will then plot the data from the file that the user selected. The code below is very simplistic, and I simply don't know how to pass the file information from the file selector to python. I need to use python to handle the file I/O and not html or javascript.</p>

<p>I can get it to work just fine when I run <code>bokeh serve --show example.py path/to/input_file</code> at the command line, but I don't want the user to specify this each time. I need them to be able to click a button to "upload" the file. This application is running locally, so there is no uploading to a server or anything like that.</p>

<p>Is there a better method than <code>&lt;input type="file"&gt;</code> ?</p>

<pre><code>from bokeh.plotting import figure
from bokeh.layouts import layout
from bokeh.models import ColumnDataSource, Div
from bokeh.io import curdoc

desc = Div(text="""
&lt;h1&gt;A simple example&lt;/h1&gt;
&lt;input type="file"&gt;
&lt;br /&gt;""", width=800)

# Create Column Data Source that will be used by the plot
source = ColumnDataSource(data=dict(x=[], y=[]))

p = figure(plot_height=550, plot_width=800, title="", toolbar_location='above')
p.line(x="x", y="y", source=source)

def update():
    x_data,y_data = read_file_data(input_file_name) # function to read specific file type
    source.data = dict(
        x=x_data,
        y=y_data,
    )

sizing_mode = 'fixed'  # 'scale_width' also looks nice with this example
l = layout([
    [desc],
    [p],
], sizing_mode=sizing_mode)

update()
curdoc().add_root(l)
curdoc().title = "Sample"
</code></pre>