Deploy Python Falcon app with Apache2

荒凉一梦 提交于 2019-12-12 03:33:24

问题


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

来源:https://stackoverflow.com/questions/39464485/deploy-python-falcon-app-with-apache2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!