【问题标题】:How to provide the information (in html) for the label selected from the option in flask webpage?如何为从烧瓶网页中的选项中选择的标签提供信息(以 html 格式)?
【发布时间】:2020-12-19 08:21:19
【问题描述】:
{% extends "layout.html" %}
{% block content %}
    <!-- DESCRIPTION -->
    <div class="row">
        <div class="col c12 aligncenter">
            <h2>List</h2>

            
        <form class="form-horizontal" action="{{ analyze }}" id="textform" method="post" enctype="multipart/form-data">
                    <h3>List of proteins</h3>
                        </label>
                        <select id="List of proteins" class="" name="LoP">                              
                                <option HREF="#table1">Muc</option>
                                <option HREF="#table2">Sph</option>
                                <option HREF="#table3">Gle</option>
                                <option HREF="#table4">gens</option>
                                <option HREF="#table5">ses</option>
                                
                            </select>

                    <div class="row">
                        <div class="col c12"> 
                            <br/><input type="submit" class="button" value="Submit"/> <input type="reset" class="button" value="Clear"/>
                        </div>

亲爱的朋友们, 这是我拥有的 HTMl 文件,一旦我选择 MUC 选项并使用 post 和 get 选项将其提交到烧瓶网页中,我想显示存储在 table1.html 文件中的信息? 你能帮我解决这个问题吗?

【问题讨论】:

    标签: html python-3.x flask


    【解决方案1】:

    首先您需要为您的选项添加 value attr。这样您将在您的烧瓶代码中获得 request.form 中的值。然后您可以决定要返回什么响应。

    【讨论】:

    • 感谢您的帮助。我尝试将 Value attr 添加到 html 文件并使用以下代码,但显示错误请求浏览器(或代理)发送了此服务器无法理解的请求。
    • @app.route('/classifications/', methods=['POST', 'GET']) def classifications(): if request.method == 'POST': query_code = request. form('Muc') return render_template('test.html') else: return render_template('classifications.html')
    • 申请表是一本字典。如果你打印它,你得到它。你的值在request.form['LoP']
    • @app.route('/classifications/', methods=['POST', 'GET']) def classifications(): if request.method == 'POST': query_code = request. form['proteins'] return render_template('test.html') else: return render_template('classifications.html') 如何为帖子中的五个数据提供html链接并获取flask。请帮帮我。
    • 像这样使用request.formif request.form['LoP'] == 'Muc' 和 ...
    猜你喜欢
    • 2023-03-20
    • 2020-03-13
    • 2014-06-18
    • 2015-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-22
    相关资源
    最近更新 更多