ash84
ash84

Reputation: 817

flask url path in Apache httpd-vhosts

Use flask and mod_wsgi.

Apache v2.4 httpd-vhost.conf below:

<VirtualHost *:80>
    WSGIScriptAlias /admin /home/service/admin
    WSGIDaemonProcess admin user=operators processes=10 threads=5 

    WSGIApplicationGroup %{RESOURCE}

   <Directory /home/service/admin>
      WSGIProcessGroup admin
      Require all granted
    </Directory>

</VirtualHost>

I set url-path to /admin.

Ajax code in html access /api/store/list:

function getStoreList(){
    $.ajax({
        url:'/api/store/list',
        type:'POST' 
    });
}

How to access /admin/api/store/list without modify url(/api/store/list=>/admin/api/store/list)?

Use mod_rewrite in Apache? Anything else in Flask?

Upvotes: 0

Views: 165

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58563

The Javascript should really be using the full URL path including mount point. If you can't handle that, then why mount your WSGI application at a sub URL in the first place?

If for some reason you cannot make the code use the correct thing, try adding in addition to what you have:

WSGIScriptAlias /api/ /home/service/admin/api/

Yes the '/api/' is being added to the end of the path to the WSGI script file as last argument. That is needed so code thinks it is still mounted at root of web site and thus URL mapping sees full '/api/store/list'.

Upvotes: 2

Related Questions