亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

python - 找不到燒瓶模板文件
ringa_lee
ringa_lee 2017-06-22 11:52:00
0
3
1949

在同級目錄下,不明白為什麼 index.html 和 視圖控制器沒有自動(dòng)綁定
, 提示鴨子類型引起的,是哪裡幹?jǐn)_了 視圖的綁定?

#那這種,app和 temeplate 在同級目錄,路徑該如何寫?
我 寫成 app =Flask(__name__,template_folder='templates'),
pycharm 左側(cè),並沒有提示 ,templates 綁定 html 的圖示

#
ringa_lee
ringa_lee

ringa_lee

全部回覆(3)
大家講道理

預(yù)設(shè)情況下模板是在同級目錄templates裡的,你這個(gè)目錄沒有創(chuàng)建。

扔個(gè)三星炸死你

這個(gè)主要原因是app在定義的時(shí)候,預(yù)設(shè)是指向templates這個(gè)目錄中的,你應(yīng)該吧index.html放到rest1的templates目錄中。
或在app=Flask(__name__, template_folder=’path’), 指定路徑
http://flask.pocoo.org/docs/0... 此為Flask API文件

Parameters:
import_name – the name of the application package
static_url_path – can be used to specify a different path for the static files on the web. Defaults to the name of the static_folder ??? be served at static_url_path. Defaults to the 'static' folder in the root path of the application.
template_folder – the folder that contains the templates that should be used by the application. Defaults to 'templates' pathp the application. Defaults to 'root .
instance_path – An alternative instance path for the application. By default the folder 'instance' next to the package or module is assumed to be the instance path.
toinstance_relative_config – if set to True relative name path. relative to the instance path instead of the application root.
root_path – Flask by default will automatically calculate the path to the root of the application. In certain situations this cannot be achieved (for application. In certain situations this cannot be achieved (for application. In certain situations this cannot be achieved (for instance if the name sname) needs to be manually defined.

要仔細(xì)閱讀文檔,裡面有寫template_folder參數(shù)讀取的目錄是以root_path為準(zhǔn),你要理解每個(gè)參數(shù)的意義。

Peter_Zhu

pycharm 設(shè)定 Mark as template folder

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板