Request.path and url_for do not match in Flask under mod_wsgi

Is there a way to get request.path in Flask that includes any “decorations” that WSGI or something else can add?

Running in test mode (only on port 5000), my request.path and url_for('settings') correspond only to a fine, but once under WSGI , as expected, my url_for('settings') becomes /manage/settings/ , but request.path yeilds /settings/ .

I have the following in my httpd.conf and I'm working on moving an application from development to a live site.

 WSGIScriptAlias /manage /sw/servermanager/servermanager.wsgi WSGIDaemonProcess servermgr user=user group=grp threads=4 <Directory /sw/servermanager> WSGIProcessGroup servermgr WSGIApplicationGroup %{GLOBAL} WSGIScriptReloading On Order deny,allow Allow from all </Directory> 

I like the idea of ​​having the templates pretty general and then displaying the navigation information on the fly using CSS. I used the technique presented in this answer to structure my views up to this point, but the problem arises when I add mod_wsgi to the equation.

I looked at the request object and did not see as much as I wanted, except perhaps using url_rule , but then the parameters evaded me.

For good measure only, the link for WSGI Script that I use: https://github.com/FernFerret/servermanager/blob/master/servermanager.wsgi

I will also be interested in the documentation for the request object, I found my way around it using the built-in debugger and help(request) .

EDIT: I have to say that the URLs do not match Apache executing mod_wsgi.

+4
source share
1 answer

This is a feature, not a mistake. Review the documentation for attributes associated with the URL, on request, and for querying the object itself .

You can use request.script_root + request.path .

+6
source

All Articles