我正在尝试使用我从下载的样板
Initializr
和bottle.py一起。我显然做错了什么,因为我只是试图加载
index.html
该站点在不使用任何样式表的情况下进行渲染,我在浏览器控制台中遇到以下错误:
Use of getUserData() or setUserData() is deprecated. Use WeakMap or element.dataset instead. requestNotifier.js:52
The stylesheet http://localhost:8080/css/normalize.min.css was not loaded because its MIME type, "text/html", is not "text/css". localhost:8080
The stylesheet http://localhost:8080/css/main.css was not loaded because its MIME type, "text/html", is not "text/css". localhost:8080
SyntaxError: syntax error modernizr-2.6.2-respond-1.1.0.min.js:1
SyntaxError: syntax error plugins.js:1
SyntaxError: syntax error
我的应用程序如下所示:
import bottle # Web server
from bottle import run, route, static_file, error, template # import request
@route('/')
def index():
return static_file('index.html', root='./html/')
@route('./css/<filename>')
def server__static(filename):
return static_file(filename, root='./css/')
if __name__ == '__main__':
# To run the server, type-in $ python server.py
bottle.debug(True) # display traceback
run(host='localhost', port=8080, reloader=True)
样式表是从
索引html
像这样:
<link type="text/css" rel="stylesheet" href="css/normalize.min.css">
<link type="text/css" rel="stylesheet" href="css/main.css">
我的基本文件夹结构是(snipped js文件夹等):
bottle_test.py
- html
index.html
- css
main.css
normalize.min.css
我明白
bottle doesn't serve static files
独自一人,我确实玩了
server-static
并添加、更改和删除
mimetype
但无法使其发挥作用。
整个样板位于
html
文件夹,应用程序确实找到
索引html
。我在Firefox和Chrome中尝试过。如果重要的话,我使用Win8.1和anaconda的python 2.7。我做错了什么?