Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 重定向时如何获取表行详细信息_Python_Html_Mysql_Flask - Fatal编程技术网

Python 重定向时如何获取表行详细信息

Python 重定向时如何获取表行详细信息,python,html,mysql,flask,Python,Html,Mysql,Flask,我正在使用Flask和MySQL创建一个基于数据库填充的表。现在,当用户单击某一行时,我需要重定向到另一个页面,该页面将告诉我有关该行的更多信息 我已经关闭了重定向部分,但是如何在后端获取关于该行的信息 以下是我的HTML代码: <tbody> {% for row in resultPois %} <tr onclick="window.document.location='/pageDetail';"> <td>{{ row

我正在使用Flask和MySQL创建一个基于数据库填充的表。现在,当用户单击某一行时,我需要重定向到另一个页面,该页面将告诉我有关该行的更多信息

我已经关闭了重定向部分,但是如何在后端获取关于该行的信息

以下是我的HTML代码:

<tbody>
    {% for row in resultPois %}
    <tr onclick="window.document.location='/pageDetail';">
        <td>{{ row[0] }}</td>
        <td>{{ row[1] }}</td>
        <td>{{ row[2] }}</td>
        <td>{{ row[3] }}</td>
        <td>{{ row[4] }}</td>
        <td>{{ row[5] }}</td>
    </tr>
    {% endfor %}
</tbody>

当您想要将变量从模板传递到后端时,您可以尝试使用(端点,**值)的
flask.url\u

烧瓶内模板:

<tbody>
    {% for row in resultPois %}
    <tr onclick="window.location.href='{{ url_for('page_detail', rowData=row) }}';">
        <td>{{ row[0] }}</td>
        <td>{{ row[1] }}</td>
        <td>{{ row[2] }}</td>
        <td>{{ row[3] }}</td>
        <td>{{ row[4] }}</td>
        <td>{{ row[5] }}</td>
    </tr>
    {% endfor %}
</tbody>

{resultPois%中的行的%s}
{{行[0]}
{{行[1]}
{{行[2]}
{{行[3]}
{{行[4]}
{{row[5]}
{%endfor%}
在烧瓶视图中:

@app.route('/pageDetail/<rowData>')
def page_detail(rowData):
    # you can use the the rowData from template
    return render_template('page_detail.html'
@app.route(“/pageDetail/”)
def页面_详细信息(行数据):
#您可以使用来自模板的行数据
返回呈现模板('page\u detail.html'
顺便说一句,我建议设计前端部分,最好将按钮设为表行中的一列,当单击按钮时,触发onclick函数调用url\u,这样会更方便用户

@app.route('/pageDetail/<rowData>')
def page_detail(rowData):
    # you can use the the rowData from template
    return render_template('page_detail.html'