我写了两个 python 文件,第一个是从 API 打印出一个字符串,另一个是使用烧瓶建立一个网站。所以在第一个文件中,我得到一个变量并将其打印出来。
firstevent = events['items'][1]['end']
在python烧瓶中,我想发送第一个事件,但第一个事件看起来像“null”
app = Flask(__name__)
@app.route("/")
def index():
return """Hello!<br/><br/>
<a href='/form'>Visit form page</a>"""
# Second Page Route
@app.route("/page2")
def page2():
return """<html><body>
<h2></h2>
<p></p>
</body></html>"""
# new route will accept both a GET and POST request from the client (web browser)
@app.route("/form", methods=["GET","POST"])
def simpleform():
# Did the client make a POST request?
if request.method == "POST":
# get the form data submitted and store it in a variable
user_name = request.form.get('user_name', 'firstevent')
# return custom HTML using the user submitted data
return "<html><body><h3>Hello %s! What an interesting name.</h3><br><a href='/form'>back to form</a></body><html>" % user_name
else:
# client made a GET request for '/form'
# return a simple HTML form that POSTs to itself
return """<html><body>
<form action="/form" method="POST">
What's your name? <input type="text" name="user_name" id="user_name"/>
<input type="submit" value="submit it"/>
</form>
</body></html>"""
if __name__ == "__main__":
app.debug = True
app.run()
如何相互通信这两个 python 文件?谢谢!