python3 bottle 外部ファイルを認識したい
#現状
HTMLファイルにアクセスできて居るかも分かりません。
現状のコード
#!/usr/bin/env python # -*- coding: utf-8 -*- # http://localhost:8080/hello from bottle import route, run, static_file @route('/hello') def hello(): return "Hello World" @route('/file/<filename:path>') def static(filename): return static_file(filename, root="/home/use/work1/static/html") run(host='localhost', port=8080, debug=True) #run(host='0.0.0.0', port=8080, debug=True, reloader=True)
#フォルダ構造
home/
1 use/ 2 Sample_Demo/ 3 work1/ 4 hello.py 5 static/ 6 html/ 7 index.html 8 js/ 9 untitled.js 10 css/ 11 default.css
bottle python 外部ファイル読み込み
#bottle 公式ページより抜粋 @route('/static/<filename>') #1 def server_static(filename): #2 return static_file(filename, root='/path/to/your/static/files') #3
解らない所
1の''の部分[何を指してるのか不明]
1の<filename>最終部分filename:pathの箇所[直接拡張子を指定しているのか、どうか?]
2の(filename)[どの様なファイルを指定するのか?]
3のfilenameと何なのか?
3のrootが示すURLはHTMLファイルが有る所で良いのか?
ルートパスが変更されて外部ファイルが読み込めない場合
ルーティングの設定方法とルートパスの視覚化[どの用にルートパスが変化したのか知りたいです]
HTMLファイルにアクセスした場合、
python側で、ファイルの拡張子を読み込んで無いのに、どうして認識されるのか?
参考サイト
https://teratail.com/questions/109710
https://bottlepy.org/docs/dev/tutorial.html#quickstart-hello-world
http://kitabatech.blogspot.com/2014/07/bottle.html
http://h2shiki.hateblo.jp/entry/2016/04/17/020526
https://tmg0525.hatenadiary.jp/entry/2018/03/04/004706
http://d.hatena.ne.jp/graySpace/20170115/1484458307
#2,3行で分かりやすく教えて欲しい箇所
コード部分の debug=Trueとreloader=Trueの意味
run(host='0.0.0.0', port=8080, debug=True, reloader=True)
reloader=Trueはサーバーを建てたまま再読込すると反映されると知りました。
debug=Trueのリロードオートは何なのでしょうか?
リロードオート
自動リロード機能とは
参考サイト
takeshid.hatenadiary.jp/entry/2015/12/15/234059
読んでも具体的に、どういったモノなのか分かりませんでした。
確認済み
reloader=True
これはbottleがコードの編集を認識し再読み込みしてくれるオプション
付けない場合は、コードの反映にbottleの停止起動が必要になります。
参考サイト
http://kitabatech.blogspot.com/2014/07/pythonbottle.html
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。