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.
預設情況下模板是在同級目錄templates裡的,你這個目錄沒有創建。
這個主要原因是app在定義的時候,預設是指向templates這個目錄中的,你應該吧index.html放到rest1的templates目錄中。
或在app=Flask(__name__, template_folder=’path’), 指定路徑
http://flask.pocoo.org/docs/0... 此為Flask API文件
Parameters:
要仔細閱讀文檔,裡面有寫template_folder參數讀取的目錄是以root_path為準,你要理解每個參數的意義。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.
pycharm 設定 Mark as template folder