我正在制作仪表板,我希望能够从.csv文件中显示所选月份的图形。这是我的.html页面
<form action="/">
<select name = "userinput">
<option selected>January</option>
<option>February</option>
<option >March</option>
<option>April</option>
<option>May</option>
{% for input in userinput %}
{% if input == current_userinput %}
<option selected value= "{{input}}">{{input}}</option>
{% else %}
<option selected value = "{{input}}"> {{input}}</option>
{% endif %}
{% endfor %}
</select>
</form>
这是我的app.py.
@application.route('/', methods=['GET', 'POST'])
def home():
current_userinput = request.args.get("userinput")
if current_userinput == None:
current_userinput = "February"
file_path = os.path.join(path_ios, current_userinput+ios)
但是当我选择下拉列表时,它没有通过所选的值,我该怎么做才能解决问题?
有什么建议??
你可以使用jQuery中的$ .ajax。
调用路由/
传递你想要的信息或只做一个GET然后用hQuery中的jQuery绘制它。
这是一个例子:
https://www.bogotobogo.com/python/Flask/Python_Flask_with_AJAX_JQuery.php