Changing default url to static-media in Flask -


i've made website using flask , have no problems getting things work on built-in development server. i've been able things running on production server under mod_wgsi. however, host static media static/cgi/php-5.2 application , can't flask 'see' without manually changing urls in html files.

the problem seems basic flask setup expects static files within flask application. see here details. essentially, think need change url of 'static' portion of following 1 liner:

<link rel="stylesheet" href="{{url_for('static', filename='css/print.css')}}" type="text/css" media="print"/>  

it looks can change in init.py, instructions here, defining static_path follows doesn't seem work.

app = flask(__name__, static_path = '/web_media') 

to clear, if manually define url this:

<link rel="stylesheet" href="/web_media/css/print.css" type="text/css" media="print"/> 

everything works fine. appreciated.

if production set flask should not serving static content; web server (nginx, apache, cherokee, etc...) should handling more efficient @ handling types of operations python process. sounds of (based on mod_wsgi reference) using apache, how could alter config file serve static content static/cgi/php-5.2 using apache.

assuming "web_media" directory under fictitious /var/www/static/cgi/php-5.2 directory , contains css/js/etc. assets. in config file, within area configure app add along lines of.

alias /web_media/ /var/www/static/cgi/php-5.2/web_media/  <directory /var/www/static/cgi/php-5.2/web_media>   order deny,allow   allow </directory> 

it's been while since used/configured apache, no guarantees above work first time. main point is, use webserver handle static media.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -