bottle想输出html,css,js,png这些静态资源文件是非常简单的,还是一个函数:static_file
使用方法:return static_file(文件名, root="文件所在目录绝对路径")
老规矩,给出demo:
~~~
# coding:UTF-8
from bottle import Bottle, static_file
app = Bottle()
@app.get('/')
def index():
return static_file("index.html", root="/var/ww/html")
app.run(host="127.0.0.1", port=8000, reloader=True, debug=True)
~~~