【问题标题】:Passing values from one html page to another via Flask (Python)通过 Flask (Python) 将值从一个 html 页面传递到另一个页面
【发布时间】:2014-08-11 02:37:48
【问题描述】:

我的网络应用目前有 3 个页面。我在第一页上获得了用户输入,并将其传递给了我的 view.py,并计算了我的第二页所需的一些变量。我想将第二页中存在的变量传递到第三页,但不知道如何去做。有关如何修改第二页的 html 以实现此目的的任何建议?

到目前为止,我通过在 view.py 中将变量设为全局变量来解决这个问题。这似乎可行,但似乎不是一个可行的长期解决方案。

谢谢!

existing variables: thePrediction, theData

第二页的html:

        <div class = "caption-full">
              <h3>Currently, I have a {{thePercentage}} chance of getting adopted.</h3>
            {% if thePrediction[1] + thePrediction[2] >0%}
                <form action="/third_page" method="GET">
                    <button class="btn btn-large btn-info" >Go to third page</button>
                </form>

            {% endif %}
        </div>

【问题讨论】:

    标签: python html twitter-bootstrap flask


    【解决方案1】:

    我想我明白了:

    <div class = "caption-full">
                      <h3>Currently, I have a {{thePercentage}} chance of getting adopted.</h3>
                    {% if thePrediction[1] + thePrediction[2] >0%}
    
                        <form action="/third_page" method="GET">
                            <input type="hidden" name="alignment" value="{{thePassedValue}}" />
                            <button class="btn btn-large btn-info" >Go to third page</button>
    
                        </form>
    
                    {% endif %}
                </div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-13
      相关资源
      最近更新 更多