python - PyCharm 找不到存在的 Flask 模板

标签 python flask pycharm

PyCharm 的代码编辑器在将 “index.html” 传递给 render_template 时显示弹出消息 Template file 'index.html' not found。模板 templates/index.html 存在。访问 http://localhost:5000/ 呈现模板。我如何告诉 PyCharm 该模板存在?

@app.route('/')
def index():
    return render_template('index.html')

enter image description here

最佳答案

右键单击您的模板目录,转到“将目录标记为”,然后选择“模板目录”。

关于python - PyCharm 找不到存在的 Flask 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45017338/

相关文章:

python - 使用 ajax 和 jquery 传递数据的简单 flask 应用程序服务器

python - 在Python Flask中: What are appropriate places to store data?

python - 如何在pycharm中递归运行文件夹中的所有doctests?

python-3.x - 为什么 Pycharm 返回向上箭头而不是清理屏幕?

python - PyCharm Jupyter 笔记本 : Add Jupyter to the interpreter of the current project

python - 复杂 Numpy 脚本的矢量化实现

python - 从 .m matlab 文件中声明的矩阵创建 numpy 数组

python - Python/numpy点列表到黑白图像区域

python - 通过 python 将表名作为 postgres 中的参数传递

python - gunicorn + flask (connexion/swagger_server) 超时/不响应 API 请求