運行 [email protected]('/articles', methods=['GET', 'POST'])def articles(): upload() return render_template('articles.html')而這個保存圖像并處理其信息的功能def upload(): if request.method == 'POST': # Save the file to static/uploads label = "some string from process above" probability = "another string" return None return None如何在渲染模板時使用變量標簽和概率?有些人使用接近于:return render_template('articles.html', label=label, probability=probability)這樣做是為了使用 js 引用變量。但是,如果它是在 upload() 內部計算的,我該如何引用該變量?需要全局變量嗎?
如何從函數外部使用 flask 變量以便以后在 javascript 中使用?
ibeautiful
2023-02-22 15:46:22