[Flask] Specify the front-end file path and static file path

The default front-end path of flask is under templates, and static files are under static

If you do not move or modify the default path of the app, you can write it directly like this:

app = Flask(__name__)
如果有修改,可以这样写:
app = Flask(__name__,template_folder='../xxxx',static_folder="../xxxx")
#template_folder='../xxxx' 指 前端文件的目录
#static_folder="../xxxx"  指 静态文件的目录
不然会报错,如 TemplateNotFound 、Uncaught SyntaxError: Unexpected token <  等实际文件存在却找不到的错误

Guess you like

Origin blog.csdn.net/u013066730/article/details/108367857