I've wrote a little flask application. I send a request with json data (python script) to the flask server (ubuntu 18.04 with python 3.6.7), and the server evaluate these data...
Client:
data = { 'serial': '12345'
'printerConfig': {
'virtualPrinter1': 'physicalPrinter1',
'virtualPrinter2': 'physicalPrinter2',
'virtualPrinter3': 'physicalPrinter3'
}
}
r = requests.get("http://127.0.0.1/webservice", json=data)
Server:
@app.route('/', methods=['GET', 'POST'])
def webservice():
if request.method == 'GET':
serial = request.json['serial'] if 'serial' in request.json else None
printerConfig = request.json['printerConfig'] if 'printerConfig' in request.json else None
I have tested this code in pyCharm with the development server and always works fine.
After that I have tried to implement that to an Apache2 server. Now I get the following error message in apache-error.log.
ERROR:flask.app:Exception on / [GET]
Traceback (most recent call last):
...
File "/var/www/html/webservice/webservice.py", line xx, in webservice
serial = request.json['serial'] if 'serial' in request.json else None
TypeError: argument of type 'NoneType' is not iterable
Print of request.json shows only None. Exactly the same code on the development server is running.
Instead of request.json I also tried request.data, with the same result.
Is there a specially setting for the Apache2? Has anyone an idea?
Best regards flo