python - pass return argument value one function to another flask -
i return value 1 function function , use filter excel. below trying do:
@app.route('/bzrules') def show_tables(): rules = pd.read_excel('static/dummy_data.xlsx') # user select value in drop down in view.html. want user selection passsed second function below filter excel sheet subarealist = rules['subject_area'].unique().tolist() return render_template('view.html', subarealist=subarealist) @app.route('/postfields') def postfields(): # user selection first function pass , select sheet excel dt = pd.read_excel('static/alldatasheets.xlsx', sheetname='user selection subarealist')
below part of view.html code :
<form action="{{ url_for('show_tables') }}" method="post"> <div class="form-group"> <div class="input-group"> <select name='fieldnames'onchange="this.form.submit()"> {% val in subarealist %} <option value='{{val}}' selected="search_key" {% if search_key==val %}{% endif%}>{{val}}</option> <option selected="selected"></option> {% endfor %}
i think want this:
<form action="{{ url_for('postfields', sheet_name=val) }}" method="post"> <div class="form-group"> <div class="input-group"> <select name='fieldnames'onchange="this.form.submit()"> {% val in subarealist %} <option value='{{val}}' selected="search_key" {% if search_key==val %}{% endif%}>{{val}}</option> <option selected="selected"></option> {% endfor %}
and change function to:
@app.route('/postfields/<sheet_name>', methods=['post']) def postfields(sheet_name): # user selection first function pass , select sheet excel dt = pd.read_excel('static/alldatasheets.xlsx', sheetname=sheet_name)
you may need change sheet_name=val
section bit, because i'm not sure kind of object val
might be, or properties have. make sure you're sending data function needs, , function set receive type of data you're sending it.
Comments
Post a Comment