python - Running webapp2 app in a multiple WSGI apps set up with Werkzeug -
i trying run django app , webapp2 app in 1 python interpreter. i'm using werkzeug described here.
here's sample code.
from werkzeug.wsgi import dispatchermiddleware django_app import application djangoapp webapp2_app import application webapp2app application = dispatchermiddleware(djangoapp, { '/backend': webapp2app })
after doing this, expect requests /backend should treated webapp2 app /. treats requests /backend. work fines other wsgi apps using django or flask. problem appears webapp2 apps. have suggestions how overcome this? there other way can achieve purpose without using werkzeug serving multiple wsgi apps under 1 domain?
dispatchermiddleware
fabricates environments apps , script_name
. django can deal with configuration varibale force_script_name = ''
(docs).
with webapp2 it's more complicated. can create subclass of webapp2.wsgiapplication
, override __call__()
method , force script_name
desired value. in webapp2_app.py
this
import webapp2 class wsgiapp(webapp2.wsgiapplication): def __call__(self, environ, start_response): environ['script_name'] = '' return super(wsgiapp, self).__call__(environ, start_response) # app = wsgiapp(...)
Comments
Post a Comment