Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return an html file in bottle server?

Tags:

python

bottle

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.

like image 996
Ramis Avatar asked Feb 17 '14 00:02

Ramis


1 Answers

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.

like image 69
kylieCatt Avatar answered Oct 18 '22 16:10

kylieCatt