-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError error and blank web while running with keras 1.2.1 #12
Comments
This is awesome thanks for sharing. This helped me get it to work. I believe there are two things we need to add here to make it work.
and @app.route("/publish/epoch/end/", methods=['POST'])
def publish():
#payload = request.form.get('data')
payload = unquote(request.data.split('=')[1]).replace('+','')
try:
data = json.loads(payload)
except:
return {'error':'invalid payload'}
def notify():
msg = str(time.time())
for sub in subscriptions[:]:
sub.put(payload)
gevent.spawn(notify)
return "OK" |
Thanks for the tip. But on one of my configs (WinPython/Python 3.5.2) I had to slightly modify the payload formatting line to add utf-8 decoding: payload = unquote(request.data.decode("utf-8").split('=')[1]).replace('+','') |
Great, thank you! |
|
When I run python api.py, and start keras program with remote callbacks, I got these message:
::ffff:127.0.0.1 - - [2017-02-14 11:51:15] "POST //publish/epoch/end/ HTTP/1.1" 500 161 0.000479
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 936, in handle_one_response
self.run_application()
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 909, in run_application
self.result = self.application(self.environ, self.start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1994, in call
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1615, in full_dispatch_request
return self.finalize_request(rv)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1630, in finalize_request
response = self.make_response(rv)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1740, in make_response
rv = self.response_class.force_type(rv, request.environ)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/wrappers.py", line 847, in force_type
response = BaseResponse(*_run_wsgi_app(response, environ))
File "/usr/local/lib/python2.7/dist-packages/werkzeug/test.py", line 871, in run_wsgi_app
app_rv = app(environ, start_response)
TypeError: 'dict' object is not callable
Tue Feb 14 11:51:15 2017 {'REMOTE_PORT': '39644', 'HTTP_HOST': 'localhost:9000', 'REMOTE_ADDR': '::ffff:127.0.0.1', (hidden keys: 23)} failed with TypeError
I checked my gevent and flask version:
So I modifed api.py like these:
Then everything goes OK
The text was updated successfully, but these errors were encountered: