mod wsgi - Python Falcon on Webfaction -
i'm trying falcon , running on webfaction. i'm not network guru, i'm having tough time wrapping head around how these applications served.
my webfaction app set mod_wsgi 4.5.3/python 2.7
to understanding, falcon run on wsgi server. when swet mod_wsgi server, automatically configured falcon run on? or still need install gunicorn?
when set webfaction app, received directory structure this:
app/htdocs/index.py
and inside index.py file, put example found @ falcon tutorial
import falcon class thingsresource(object): def on_get(self, req, resp): """handles requests""" resp.status = falcon.http_200 resp.body = 'hello world!' # falcon.api instances callable wsgi apps wsgi_app = api = falcon.api() # resources represented long-lived class instances things = thingsresource() # things handle requests '/things' url path api.add_route('/things', things)
i understand there instructions running wsgi, confusion @ - webfaction server running wsgi, or still need gunicorn, , if - best way configure? need cron keep running gunicorn?
thanks!
update:
i checked error logs , received wsgi error not having variable named "application",
so changed:
wsgi_app = api = falcon.api()
to:
application = falcon.api()
this cleared out error, when visit mydomain.com/things, error 404 (not found / not exist).
so, brings me original question of next steps are? seems if url isn't being routed correctly, httpd.conf file or similar - again, first go @ getting set live.
here answer (at least initial question, i'm willing bet i'll mess else in near future on same project).
essentially, able put tutorial code in index.py file webfaction generates when setting app & mounting on domain. so, tutorial code looks this:
import falcon class thingsresource(object): def on_get(self,req,resp): resp.status = falcon.http_200 resp.body = 'hello world!' api = application = falcon.api() things = thingsresource() api.add_route('/things', things)
since couldn't find info launching falcon app on webfaction, looked @ how similar applications run on webfaction (flask in example). being said, found snippet on flask docu showing how set on webfaction. i'm not sure if means entire application work, know falcon tutorial code @ least works. essentially, had edit httpd.conf file per instructions found here: flask webfaction
wsgipythonpath /home/yourusername/webapps/yourapp/htdocs/ #if not specify following directive app *will* work #see index.py in path of urls wsgiscriptalias / /home/yourusername/webapps/yourapp/htdocs/index.py <directory /home/yourusername/webapps/yourapp/htdocs/> addhandler wsgi-script .py rewriteengine on rewritebase / wsgiscriptreloading on </directory>
i hope helps similar issue.
Comments
Post a Comment