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)
index.html
スタイルシートは次のように呼び出されます。
<link type="text/css" rel="stylesheet" href="css/normalize.min.css">
<link type="text/css" rel="stylesheet" href="css/main.css">
私の基本的なフォルダー構造は(切り取られたjsフォルダーなど)です:
bottle_test.py
- html
index.html
- css
main.css
normalize.min.css
ボトルはそれ自体では静的ファイルを提供しないことを理解しており、ルートをserver-static
いじって引数を追加、変更、および削除しましたが、動作さmimetype
せることができません。
ボイラープレート全体がhtml
フォルダーにあり、アプリはindex.html
. FirefoxとChromeでこれを試しました。私はWin 8.1とanacondaのpython 2.7を使用しています。私は何を間違っていますか?