1

我使用 falcon 框架(v1.0)开发了一个 api。现在,我想在亚马逊 EC2 实例上使用 mod_wsgi 在 apache2 服务器上部署这个 api。

我在 EC2 服务器上使用 wsgiref 包运行我的应用程序。

import falcon
from wsgiref import simple_server

api = app = falcon.API()

class Resource(object):
    def on_get(self, req, resp):
        print("i was here :(")
        if 'fields' in req.params:
            print(req.params['fields'])
            print(len(req.params['fields']))
            print(type(req.params['fields']))

res = Resource()
api.add_route('/', res)

if __name__ == '__main__':
    http = simple_server.make_server('0.0.0.0', 8000, app)
    http.serve_forever()

当我调用https://example.com:8000/时,我没有得到任何响应,而且我的服务器也没有收到请求。

wsgi.py 文件包含:

from test import app as application

我在 /etc/apache2/sites-available/000-default.conf 添加了以下几行

 WSGIDaemonProcess test python-path=/var/www/test/test:/var/www/test/env/lib/python3.4/site-packages
 WSGIProcessGroup test
 WSGIScriptAlias / /var/www/test/wsgi.py
4

0 回答 0