How to actively watch for a selected file from a FileInput widget in the same jupyter cell?

I have the following code, which works as intended except for the fact that if I paste all the code in the same Jupyter cell it won’t work:

How can I adjust the code such that I can immediately access df in the same Jupyter cell?

Code as text:

import panel as pn    
import pandas as pd
from io import BytesIO

uploadFile = pn.widgets.FileInput(accept=".csv")

def get_data_from_file(file):
    if file is not None:
        df = pd.read_csv(BytesIO(file))
        return df
get_df = pn.bind(get_data_from_file, uploadFile)

df = get_df()

Or is the current best practices to have a “confirm” button after selecting a file? How would I add a button to do this?