Using External Files in Bottle

46 views
Skip to first unread message

Wesley May

unread,
Nov 29, 2012, 8:03:41 AM11/29/12
to csc-32...@googlegroups.com
If you have some external files that you want to link to in your webpage, like CSS files, or images, you need to use Bottle's static_file function. Take a look at 5.py and 5.html in my tutorial examples (which are available on a different post). In the HTML we refer to a file "static/5.css", however in Bottle we tell it that anything that goes to that "static/" URL will actually find its content in a folder called "folder".

While clunky, you need to do it this way because Bottle doesn't know that "static/5.css" refers to a folder on your machine. It just looks like another pseudo-URL like the other examples. Note that "hello/" and "login/" and whatnot weren't real folders either in the other examples.
Reply all
Reply to author
Forward
0 new messages