bottlepy / bottle

bottle.py is a fast and simple micro-framework for python web-applications.
http://bottlepy.org/
MIT License
8.37k stars 1.46k forks source link

ResourceManager for static files (e.g. css, jss)? #439

Open Globegitter opened 11 years ago

Globegitter commented 11 years ago

Hey, I just got started with bottlepy and am looking for a way to provide static files, such as bootstrap.css or jQuery. I did find a way with static_file and app.get_url. Though I am just curious, would it be possible to do the same thing with ResourceManager as well? There is not much documentation on it and I couldn't really find any examples. It would be great if there would be some example for that (if it is for what I think it is).

iurisilvio commented 11 years ago

I created a gist example: https://gist.github.com/4579043

You can use a ResourceManager to handle it, but you still need static_file to serve these files. It is not recommended to use static_file to serve your JavaScript and CSS files.

Globegitter commented 11 years ago

Ah, thanks for the example. So what is recommended for serving js and CSS files? I only found examples using static_file and get_url e.g. http://stackoverflow.com/questions/6978603/how-to-load-a-javascript-or-css-file-into-a-bottlepy-template

iurisilvio commented 11 years ago

In production, you may use a better server to handle these static files, but it is fine for small apps. Sorry, this unrelated comment was not good here. =)