简体   繁体   English

我应该将这些奇怪的文件放在 Flask 应用程序的文件结构中的什么位置?

[英]Where should I put these strange files in the file structure for Flask app?

So I downloaded a template for a website, with the aim to use it in my Flask app.所以我下载了一个网站模板,目的是在我的 Flask 应用程序中使用它。 I know the basic file structure of Flask app is this:我知道 Flask app 的基本文件结构是这样的:

-app
 app.py
 -static
  -images
    -image files
  -style
    -css files
 -templates
  -html files

But when I opened the folder of the template code, I found all these strange files and I couldn't decide where to put them.但是当我打开模板代码的文件夹时,我发现所有这些奇怪的文件,我无法决定将它们放在哪里。

The original files:原始文件:

在此处输入图像描述

So I put the css, fonts, images, js folders into the static folder and left the rest of the files in the templates folder along with index.html (ignore index - Copy.html , that is a copy I made of the original index.html file), updated the paths of css and js files inside the HTML document and executed app.py. So I put the css, fonts, images, js folders into the static folder and left the rest of the files in the templates folder along with index.html (ignore index - Copy.html , that is a copy I made of the original index.html文件),更新了 HTML 文档中 css 和 js 文件的路径并执行了 app.py。

The file ran but most of the text of index.html was not loading and only one image was being displayed.该文件已运行,但 index.html 的大部分文本未加载,仅显示一张图像。 I checked the logs in the command line terminal and discovered that most of the css was not even getting called.我检查了命令行终端中的日志,发现大多数 css 甚至都没有被调用。

What am I doing wrong?我究竟做错了什么? How should I arrange these files?我应该如何安排这些文件?

In your html file you should connect styles in this way:在您的 html 文件中,您应该以这种方式连接 styles:

<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/style.css') }}">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM