How to return an html file in bottle server?

Ramis picture Ramis · Feb 17, 2014 · Viewed 11.3k times · Source

So I have a bottle web framework running but I would like to have one webpage in it.

I have already created the webpage in html and css but I'm not sure how to make bottle use it. I have it displaying just the html but the css part of it does not work.

I've tried googling around but I can't seem to find an example of this.

@get('/test')
def test():
    return static_file('index.html' , root="views")

My css files are in the same directory as the views folder.

Answer

kylieCatt picture kylieCatt · Feb 17, 2014
from bottle import static_file


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

This is the code that the Bottle docs give for serving a static file.