laciel拉希尔
2021-05-24 11:15
采纳率: 100%
浏览 42

flask前后交互,python?

if __name__ == '__main__':
    with open('commandcode.json') as commandcode:
        head_baowen = json.load(commandcode)
        running_head_baowen = head_baowen["total_baowen_head"]["running_state_data"]
        operation_head_baowen = head_baowen["total_baowen_head"]["operation_move"]
        data_baowen = head_baowen["total_baowen_head"]["data_baowen"]
        addr = (head_baowen['addr']['addr1'][0], head_baowen['addr']['addr1'][1])

    app.run(debug=True, host='127.0.0.1', port=8000)


@app.route("/suspend", methods=["POST"])
def web_command_suspend():
    b = operation_type('2', message_add(data_baowen))
    send_move_command(operation_head_baowen, b, addr)

    return {"msg": "suspend"}


 

 

错误:

Traceback (most recent call last):
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2069, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2054, in wsgi_app
    response = self.handle_exception(e)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2051, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1501, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1499, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1485, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "D:\work\KC\html_test.py", line 94, in web_command_suspend
    send_move_command(operation_head_baowen, b, addr)
TypeError: send_move_command() missing 1 required positional argument: 'addr'

send_move_command()只有3个参数位置

错误提示是缺少addr的位置,没有设置self,这种情况是一定要写个类的实例才行吗?

 

5条回答 默认 最新

相关推荐 更多相似问题