Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Falconframework应用程序未与gunicorn一起运行_Python_Gunicorn_Falconframework - Fatal编程技术网

Python Falconframework应用程序未与gunicorn一起运行

Python Falconframework应用程序未与gunicorn一起运行,python,gunicorn,falconframework,Python,Gunicorn,Falconframework,我有一个简单的falcon应用程序: import falcon class ThingsResource: def on_get(self, req, resq) : #"""Handels GET requests""" resp.status = falcon.HTTP_200 resp.body = '{"message":"hello"}' app = falcon.API() things = Things

我有一个简单的falcon应用程序:

import falcon

class ThingsResource:
    def on_get(self, req, resq) :
        #"""Handels GET requests"""
        resp.status = falcon.HTTP_200
                resp.body = '{"message":"hello"}'


app = falcon.API()
things = ThingsResource()
app.add_route('/things', things)
我正在尝试使用gunicorn以这种方式运行它:

arif@ubuntu:~/dialer_api$ gunicorn things:app
但是当我尝试将它与
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>
arif@ubuntu:~$http本地主机:8000/件事
HTTP/1.1500内部服务器错误
连接:关闭
内容长度:141
内容类型:text/html
内部服务器错误
内部服务器错误


这太琐碎了,我不知道这里出了什么问题?

你的第七行,在不应该的时候缩进了。 您的第6行指的是resq,而不是您稍后使用的resp。 这意味着后面提到resp的行失败了

每当您出现这样的内部服务器错误时,通常都是由于错误代码造成的。你的gunicorn进程应该已经吐出了错误。我附上了您的代码的更正版本,包括确保它符合python的约定(例如,每个缩进4个空格)。像,这样的工具可以帮助您处理像这样的小代码片段,特别是间距问题

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)

将此代码保存到另一个文件中,然后运行diff以查看我所做的更改。主要问题是resp和不适当的缩进。

您的第7行在不应该缩进的时候缩进了。 您的第6行指的是resq,而不是您稍后使用的resp。 这意味着后面提到resp的行失败了

每当您出现这样的内部服务器错误时,通常都是由于错误代码造成的。你的gunicorn进程应该已经吐出了错误。我附上了您的代码的更正版本,包括确保它符合python的约定(例如,每个缩进4个空格)。像,这样的工具可以帮助您处理像这样的小代码片段,特别是间距问题

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)

将此代码保存到另一个文件中,然后运行diff以查看我所做的更改。主要问题是resp和不适当的缩进。

您的第7行在不应该缩进的时候缩进了。 您的第6行指的是resq,而不是您稍后使用的resp。 这意味着后面提到resp的行失败了

每当您出现这样的内部服务器错误时,通常都是由于错误代码造成的。你的gunicorn进程应该已经吐出了错误。我附上了您的代码的更正版本,包括确保它符合python的约定(例如,每个缩进4个空格)。像,这样的工具可以帮助您处理像这样的小代码片段,特别是间距问题

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)

将此代码保存到另一个文件中,然后运行diff以查看我所做的更改。主要问题是resp和不适当的缩进。

您的第7行在不应该缩进的时候缩进了。 您的第6行指的是resq,而不是您稍后使用的resp。 这意味着后面提到resp的行失败了

每当您出现这样的内部服务器错误时,通常都是由于错误代码造成的。你的gunicorn进程应该已经吐出了错误。我附上了您的代码的更正版本,包括确保它符合python的约定(例如,每个缩进4个空格)。像,这样的工具可以帮助您处理像这样的小代码片段,特别是间距问题

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)
将此代码保存到另一个文件中,然后运行diff以查看我所做的更改。主要问题是resp和不适当的缩进