@app.route('/bInfo', methods = ['POST', 'GET'])
def create():
result = []
....
return jsonify(result)
我想从'/bInfo'发出请求
@app.route('/')
def index():
js = request.json('/bInfo') #this is not working
print(js)
return render_template('index.html')
我怎么能那样做呢?
无论如何,您可以执行以下操作之一:
1。在路由之外重构/bInfo
的内容。
这是不言自明的。你只需要将生成内容的代码移到外部,并在两个路由中调用它。
2。从请求中使用requests.get()
请求您需要的页面并使用它。
你需要从本地主机请求,这将使一个路由依赖于另一个路由。选项1 更安全。