【发布时间】:2021-05-13 22:20:11
【问题描述】:
所以在我使用烧瓶将 HTML 输入存储在 python 变量中之后。如何在不同的路径文件中使用此变量,即:[我已将相应 LOC 旁边的问题注释掉]
/example.html
<input type=text name=inputStr>
<button type=submit>Submit</button>
/main.py
@app.route("/example", methods=['POST'], ['GET'])
def example():
if request.method=='POST':
string=request.form["inputStr"] # suppose this is the variable i'd like to use in a diff file
return render_template("example.html")
/examplefile.py
from main import string # this does not seem to work, as you can see i'd like to import the string here
examplestring = string
print(examplestring)
【问题讨论】: