TypeError:__ call __()得到一个意外的关键字参数'mimetype'

时间:2016-03-03 11:58:10

标签: python flask

使用重定向在flask中发送响应会出现此错误:

TypeError: __call__() got an unexpected keyword argument 'mimetype'

以下是完整的跟踪:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/goelakash/mydev/demo/upload.py", line 63, in index
    return redirect(url_for("index"),code=200,Response=Response)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/utils.py", line 379, in redirect
    (escape(location), display_location), code, mimetype='text/html')
TypeError: __call__() got an unexpected keyword argument 'mimetype'

烧瓶代码是:

@app.route('/', methods=['GET', 'POST'])
def index():
    global image,pipeline

    uform = UploadForm()
    pform = PipelineForm()

    if pform.validate_on_submit():
        operation = pform.select_op.data
        op = lst[operation][1]
        pipeline.append(op)

        if image != None:
            file_location = os.path.join(app.static_folder, image)
            script_location = os.path.join(app.static_folder, "scripts/"+pipeline[-1]+".py")
            print file_location, script_location
            call(["python",script_location,file_location])


    elif uform.validate_on_submit():
        if hasattr(uform.image_file.data,'filename'):
            pipeline = []
            image = 'temp/' + uform.image_file.data.filename
            uform.image_file.data.save(os.path.join(app.static_folder, image))

    Response = make_response(render_template('index.html', uform=uform, pform=pform, image=image, pipeline = pipeline))
    return redirect(url_for("index"),code=200,Response=Response)

0 个答案:

没有答案