如何解决python脚本中的名称错误

时间:2019-07-04 18:20:21

标签: python-3.x flask

我有两个py脚本,一个是((test_procedure.py),它只是从网页上获取输入并将输出作为字典发送到另一个使用flask API的py(app.py)脚本的函数。来自app.py的function(dosomething)函数的变量(store_output_dic)来显示图表以及在test_procedure.py中捕获的值。尽管变量正确返回,但在print语句中出现Name错误。请问是什么原因。

test_procedure.py contains below code 
Def dosomething(input):
    process input
    store_output_dict{ 
        a:out1
        b:out2
        }
    return store_output_dic
app.py contains below code
from flask import Flask
from flask import Markup
from flask import render_template
from flask import request
import test_procedure as model
app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def index():
    if request.method == 'POST':
        print("===============================")
        vals = model.dosomething(request.form.get('userinput'))
        print('modeloutput:',store_output_dic)
        print("===============================")
    labels = ['label1', "label2']
    return render_template('chart.html', values=store_output_dic, labels=labels)

if __name__ == "__main__":

    app.run(host="localhost", port=0001)

0 个答案:

没有答案