Today, we use Python to implement the restful interface of Flask, and then call it wrong.
ValueError: View function did not return a response
The code is as follows:
@app.route('/xxxx/yyyy_zzzzz', methods=['POST', 'GET'])
def receive():
param = request.json
print(param)
The reason for the error is that the restful interface of flag must have a return value.
Therefore, modify the code to add the return value:
Add: return XXXX
For example:
@app.route('/xxxx/yyyy_zzzzz', methods=['POST', 'GET'])
def receive():
try:
if not request.json:
return jsonify({'code': -1, 'message': 'request is not json'})
param = request.json
return jsonify({'code': 0, 'status': 'running'})
except Exception as e:
print(e)
return jsonify({'code': -1, 'error_message':e})
Read More:
- Arrow function should not return assignment no-return-assign
- Clion breakpoint not triggered debugging no response to solve the problem
- python reads csv file is an error _csv.Error: iterator should return strings, not bytes (did you open the file in text)
- [Solved] Error handling response: TypeError: self.processResponse is not a function
- To solve the problem, start eclipse and return exit code = 13
- JMeter running error response code: non HTTP response code: java.lang.illegalargumentexception find and solve
- seaborn.load_ Data set error urlerror: < urlopen error [winerror 10060] the connection attempt failed because the connecting party did not reply correctly after a period of time or the connected host did not respond
- Under the “return-d” mode, the number of “return / return” is 1
- Waitpid call return error prompt: no child processes problem
- JS Ajax request is successful, the response displays “failed to load response data”
- Solving the problem of joi. Validate is not a function
- Solve the problem of request method ‘get’ not supported
- To solve the problem of flashback of calling class function of glutsolidcube() in Win32 program
- Solve the problem that power view in Excel prompts activate method of oleobject class failed or activate method like oleobject is invalid
- Esp32 / 8266 uses arduinoota function to show no response from device
- Vue element UI uses this. $notify is not a function problem resolution using the notification box
- Solve the problem that the delete request is not available under SpringBoot. There was an unexpected error (type=Method Not Allowed, status=405).
- Solve the problem of incomplete search results of outlook search function
- Error: Module did not self-register
- Solve the problem that springboot does not scan @ repository