python - Falcon app not running under gunicorn -
i have trivial falcon app :
import falcon class thingsresource: def on_get(self, req, resq) : #"""handels requests""" resp.status = falcon.http_200 resp.body = '{"message":"hello"}' app = falcon.api() things = thingsresource() app.add_route('/things', things)
i'm trying run using gunicorn way :
arif@ubuntu:~/dialer_api$ gunicorn things:app
but when when try connect httpie
:
arif@ubuntu:~$ http localhost:8000/things http/1.1 500 internal server error connection: close content-length: 141 content-type: text/html <html> <head> <title>internal server error</title> </head> <body> <h1><p>internal server error</p></h1> </body> </html>
this trivial, don't what's going wrong here?
your 7th line, indented when shouldn't be. 6th line refers resq, instead of resp use later. means later lines refer resp fail.
whenever have internal server errors this, it's because of faulty code. gunicorn process should have been spitting out errors. i've attached corrected version of code, including making sure fits python's conventions (4 spaces per indent, instance). tools online python code checker, can small snippets of code this, issues spacing.
import falcon class thingsresource(): def on_get(self, req, resp): resp.status = falcon.http_200 resp.body = '{"message":"hello"}' app = falcon.api() things = thingsresource() app.add_route('/things', things)
save code file, , run diff see i've changed. main issue resp , inappropriate indentation.
Comments
Post a Comment