Forums

static_file with bottle

Hi, im new to pythonanywhere, and i have a little problem, on my local apps i serve static files like this:

@get('/<filename:re:.*\.css>')
def stylesheets(filename):
        return static_file(filename, root='static/css')

Mi folder tree is something like this:

-MywebApp
---- server.py
---- /views
    | ---- index.tpl
---- /static
    | ---- /css
          | ---- style.css

With this config i can server .css files and also images, .js, etc.

But how can i server the static files without modifying my code and my app folder hierarchy? Thanks!

If you enter a static file mapping on the "Web" page it should work. Just set the "URL" field to "/static/" and the directory to "/home/jesuscc29/MywebApp/static" (adjusting the second path if your web app is in a different directory).

Thanks for the answer, but i cant do it work. I set the "URL" to "/static/" and the path to "/home/jesuscc29/blog/static" inside my static folder is a "css" folder. And nothing happend, the stylesheet is not working on the template, also, if i view the code of the html page, the link to the "css" is "jesuscc29.pythonanywhere.com/style.css". I dont know what im doing wrong?.

Did you reload the web app?