使用Apache2部署Python Falcon应用程序

时间:2016-09-13 07:31:52

标签: python-3.x apache2 mod-wsgi falconframework

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

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

SET serveroutput ON;

BEGIN
  FOR c_Emp IN (SELECT e.*, rownum FROM emp e)
  LOOP
    dbms_output.put_line('The record processed by the cursor ' || c_Emp.rownum);
  END LOOP;
end;

当我拨打https://example.com:8000/时,我没有得到任何回复,而且我的服务器也没有收到请求。

wsgi.py文件包含:

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()

我已将以下行添加到/etc/apache2/sites-available/000-default.conf

from test import app as application

0 个答案:

没有答案