[Flask] Access to /static (static files) when deployed with cgi

Young,Spencer P spenceryoung at ufl.edu
Thu Dec 8 10:16:16 EST 2016


Hi there!

What I believe you're looking for is the `static_url_path` argument to the application object. See: http://flask.pocoo.org/docs/0.11/api/#application-object

You could store this value in an environment variable or config file on your development and production system so it does not require a code change between your production and development server.

Is the app behind a proxy (IE running on localhost or some remote machine) ?
If so, you might be looking for is the ProxyFix middleware. http://werkzeug.pocoo.org/docs/0.11/contrib/fixers/#werkzeug.contrib.fixers.ProxyFix

Does that help you?

Cheers,
-Spencer


From: Flask [mailto:flask-bounces+spenceryoung=ufl.edu at python.org] On Behalf Of Per Låås
Sent: Thursday, December 08, 2016 9:42 AM
To: flask at python.org
Subject: [Flask] Access to /static (static files) when deployed with cgi

Hi!

I am new to flask and have deployed a flask web application based on a flask demo-project with cgi: ScriptAlias /flaskutforskning /path/flaskutforskning/flaskutforskning.cgi in production on the linux server, deployed following instructions at http://flask.pocoo.org/docs/0.11/deploying/cgi/. Se also file tree below.

I run the development-server in Visual Studio in my PC using from runserver.py, created by the VS Python tools - Flask web project, which I guess uses WSGI. See screen images below.

The application works fine except the links to static-files are different in development in Visual Studio and in production on the linux server. See file hierarchy below.

Development-server in Visual Studio in my PC
http://localhost:PORT/static/scripts/SPAshowresult.js

In production server:
http://www.mydomain.com/flaskutforskning/flaskutforskning/static/scripts/SPAshowresult.js

Questions:

·         Does anybody have a suggestion how to find a better way to work with paths so there is the same static path in dev and production?

·         Is there a better IDE than Visual Studio for development and debugging in the code, step by step?

Thank you so much in advance.

Best regards,

Per Låås

[cid:image001.jpg at 01D2513B.84FA6B50]
[cid:image002.jpg at 01D2513B.84FA6B50]
.
--- flaskutforskning
-- -  --- __init__.py
-- -  --- static
-- -  -- -  --- content
-- -  -- -  -- -  --- bootstrap.css
-- -  -- -  -- -  --- bootstrap.min.css
-- -  -- -  -- -  --- site.css
-- -  -- -  --- fonts
-- -  -- -  -- -  --- glyphicons-halflings-regular.eot
-- -  -- -  -- -  --- glyphicons-halflings-regular.svg
-- -  -- -  -- -  --- glyphicons-halflings-regular.ttf
-- -  -- -  -- -  --- glyphicons-halflings-regular.woff
-- -  -- -  --- scripts
-- -  -- -      --- autocomplete.js
-- -  -- -      --- bootstrap.js
-- -  -- -      --- bootstrap.min.js
-- -  -- -      --- jquery-1.10.2.intellisense.js
-- -  -- -      --- jquery-1.10.2.js
-- -  -- -      --- jquery-1.10.2.min.js
-- -  -- -      --- jquery-1.10.2.min.map
-- -  -- -      --- jquery.validate.js
-- -  -- -      --- jquery.validate.min.js
-- -  -- -      --- jquery.validate.unobtrusive.js
-- -  -- -      --- jquery.validate.unobtrusive.min.js
-- -  -- -      --- jquery.validate-vsdoc.js
-- -  -- -      --- modernizr-2.6.2.js
-- -  -- -      --- _references.js
-- -  -- -      --- respond.js
-- -  -- -      --- respond.min.js
-- -  -- -      --- SPAshowresult.js
-- -  --- templates
-- -  -- -  --- about.html
-- -  -- -  --- contact.html
-- -  -- -  --- dynfragasr.html
-- -  -- -  --- dynfrageladan - Copy.html
-- -  -- -  --- dynfrageladan.html
-- -  -- -  --- extendslayout.html
-- -  -- -  --- fragasr.html
-- -  -- -  --- frageladan - Copy (2).html
-- -  -- -  --- frageladan - Copy.html
-- -  -- -  --- frageladan.html
-- -  -- -  --- frageladan_origSPA.html
-- -  -- -  --- index.html
-- -  -- -  --- layout.html
-- -  -- -  --- test.html
-- -  --- utils.py
-- -  --- views.py
-- -  --- views - test.py
--- flaskutforskning.cgi
--- svnupdate.log
--- svnupdate.sh

6 directories, 45 files


--
Per Låås
Developer
Institutet för språk och folkminnen
www.sprakochfolkminnen.se<http://www.sprakochfolkminnen.se/>

+46 18 652 446
per.laas at sprakochfolkminnen.se<mailto:per.laas at sprakochfolkminnen.se>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20161208/45246b1a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 18942 bytes
Desc: image001.jpg
URL: <http://mail.python.org/pipermail/flask/attachments/20161208/45246b1a/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 27491 bytes
Desc: image002.jpg
URL: <http://mail.python.org/pipermail/flask/attachments/20161208/45246b1a/attachment-0003.jpg>


More information about the Flask mailing list