0
votes

Im having problems showing PDFs in a python falsk web app I'm trying to deploy. https://localhost/wsgi/users/TTG/journeys/cbwapw.pdf I get:
{"message": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again."} and access.log:
"GET /wsgi/users/TTG/journeys/cbwapw.pdf HTTP/1.1" 404 137

I can confirm the path is correct and the file does exist. I can place a html file in there and can access it. so it appears to be specific to pdf mime types? Having searched around I found some good info:
www.devside.net/wamp-server/forcing-a-pdf-or-doc-to-open-in-browser-rather-than-downloading
www.thingy-ma-jig.co.uk/blog/06-08-2007/force-a-pdf-to-download
I'm trying to open the file in browser so I added:
< LocationMatch ".(?i:pdf)$">
ForceType application/pdf
Header set Content-Disposition inline
< /LocationMatch>
Also tried:
< FilesMatch ".(?i:pdf)$">
ForceType application/octet-stream
Header set Content-Disposition inline
< /FilesMatch>
I'm running my wsgi app from c:\wsgi
I've got C:\Program Files\Apache Software Foundation\Apache22\conf\httpd.conf with:
WSGIScriptAlias /wsgi "C:/wsgi_app/OptimiserWeb.wsgi"
< Directory "C:/wsgi_app">
AllowOverride None
Options +ExecCGI
Order deny,allow
Allow from all
< /Directory>
I've tried to add my FilesMatch here both inside and outside the < Directory "C:/wsgi_app"> But this has not effect.
The pdf is actually in: C:\wsgi_app\users\TTG\journeys (I've also got LoadModule headers_module modules/mod_headers.so at the top of the httpd.conf)

I've also tried editing:
C:\Program Files\Apache Software Foundation\Apache22\conf\extra httpd-ahssl.conf and httpd-vhosts.conf
by adding < FilesMatch> inside < VirtualHost>
And tested having restarted apache, firefox, cleared ff history etc to no avail.

I'm probably missing something really obvious like where I'm putting the < FilesMatch> or how the rest of the VirtualHost should be configured ie documentRoot for my wsgi app running of c:\wsgi?
Would appreciate any help I can get. Regards Raf

1
I just noticed xml tags have disappeared when I posted my question what I meant I've got this in httpd.conf : "WSGIScriptAlias /wsgi "C:/wsgi_app/OptimiserWeb.wsgi" <Directory "C:/wsgi_app"> AllowOverride None Options +ExecCGI Order deny,allow Allow from all </Directory>" - user3728558

1 Answers

0
votes

Looks the reason my configurations are not taking effect is due to api.add_resourece() in the py file which maps those requests to a handler. Now I need to work out how to replace send_from_directory(,,) to get apache to handle the request.
Thanks and sorry to have wasted any ones time.