Discussion:
[bottlepy] What is the way to reference an image from within a bottle template?
n***@gmail.com
2018-09-23 07:05:38 UTC
Permalink
When within a bottle template file, what is the way to reference a static
file? for example this one?

<body background='/static/img/digital.gif'>

Why the above relative file fails to load the image? How can i reference it
correctly? If i try it as:

<body background="{{ static_file( 'digital.gif', root='./static/img' }}">

The image also fail to render.

Why Bottle fail to render the image even if no 'static_file' function is
used?
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marcel Hellkamp
2018-09-23 12:18:35 UTC
Permalink
Post by n***@gmail.com
When within a bottle template file, what is the way to reference a
static file? for example this one?
|<body background='/static/img/digital.gif'>|
Why the above relative file fails to load the image?
Th above example instructs the browser to load the image from
Loading Image.... Make sure the
image is reachable under that URL. You need something like this on
server site:

@route('/static/<filename:path>')
def server_static(filename):
    return static_file(filename, root='/path/to/your/static/files')

By the way, the '<body background=...>' is deprecated and not supported
in HTML5. If your template generates a HTML5 file, the browser might
just ignore unsupported tags or attributes it.
Post by n***@gmail.com
|<body background="{{ static_file( 'digital.gif', root='./static/img' }}">|
The image also fail to render.
How is that supposed to work?
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...