Deploy Python Falcon app with Apache2

2019-09-04 05:51发布

问题:

I have developed an api using falcon framework (v1.0). Now, I want to deploy this api on apache2 server with mod_wsgi at amazon EC2 instance.

I'm running my app using wsgiref package on EC2 server.

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

When I call https://example.com:8000/, I don't get any response and also my server is not getting the request.

wsgi.py file contains:

from test import app as application

I've added following lines to /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