簡體   English   中英

通過Flask(Python)將值從一個html頁面傳遞到另一個頁面

[英]Passing values from one html page to another via Flask (Python)

我的網絡應用目前有3頁。 我在第一頁上獲得了一個用戶輸入,我將其傳遞給了我的view.py,並計算了我的第二頁所需的一些變量。 我想將第二頁中存在的變量傳遞給第三頁,但不知道如何去做。 有關如何修改第2頁的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>

我想我弄清楚了:

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM