Skip to content Skip to sidebar Skip to footer

What Is The Way To Reference An Image From Within A Bottle Template?

When within a bottle template file, what is the way to reference a static file? for example this one? Why the above relative file

Solution 1:

You should add a route to your application that will return static files when they are requested. Then use the paths in html as normal paths.

So add this:

@app.route('/static/<filepath:path>')defserver_static(filepath):
    return static_file(filepath, root='/path/to/static')

then accessing: http://localhost:8080/static/file.txt will return '/path/to/static/file.txt'.

Sub-folders of '/path/to/static' will also be accessible.

Solution 2:

i'm trying to figure out how to enable error output to the browser instead of logginf via ssh all the time and 'tail -f error_log' ?

In dev instance we just did debug =True, now in the production server? Here is my config:

DocumentRoot /home/nikos/public_html

<Directory /home/nikos/public_html>
    Require all granted
</Directory>


Alias /static /home/nikos/public_html/static

<Directory /home/nikos/public_html/static>
    Options +Indexes
</Directory>


WSGIPassAuthorization On

WSGIDaemonProcess clientele user=nikos group=nikos home=/home/nikos/public_html
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py process-group=clientele application-group=%{GLOBAL}

WSGIDaemonProcess downloads user=nikos group=nikos home=/home/nikos/public_html
WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py process-group=downloads application-group=%{GLOBAL}

WSGIDaemonProcess www user=nikos group=nikos home=/home/nikos/public_html
WSGIScriptAliasMatch ^/(?!phpmyadmin) /home/nikos/public_html/www.py process-group=www application-group=%{GLOBAL}

Also i would like to know how how to grab the authuser value entered in authentication prompt so to have it stored when entered. request.auth.user' won't return it norrequest.auth.username'.

Post a Comment for "What Is The Way To Reference An Image From Within A Bottle Template?"