Flask入门教程com/你的用户名/watchlist 查看你的仓库内容。 提示 你可以在 GitHub 上查看本书示例程序的对应 commit:1b6fe4a。 进阶提示 阅读 MDN 的 《Web 入门教程》(了解 HTML、CSS、JavaScript)。 阅读短教程《Git 简明指南》。 阅读文章《Pipenv:新一代Python项目环境与依赖管理工具》或 Pipenv 官方 文档。 如果你打算开源你的程序,在项目根目录中添加一个 板》找到,Faker 相关内容可以在第 7 章找到。 第 3 章:模板 28 第 4 章:静态文件 静态文件(static files)和我们的模板概念相反,指的是内容不需要动态生成的文 件。比如图片、CSS 文件和 JavaScript 脚本等。 在 Flask 中,我们需要创建一个 static 文件夹来保存静态文件,它应该和程序模 块、templates 文件夹在同一目录层级,所以我们在项目根目录创建它: images,把这两个图片都放到这个文件夹里: $ cd static $ mkdir images 创建子文件夹并不是必须的,这里只是为了更好的组织同类文件。同样的,如果你 有多个 CSS 文件,也可以创建一个 css 文件夹来组织他们。下面我们在页面模板 中添加这两个图片,注意填写正确的文件路径: templates/index.html:添加图片0 码力 | 127 页 | 7.62 MB | 1 年前3
Flask Documentation (1.1.x)for you. Static Files Dynamic web applications also need static files. That’s usually where the CSS and JavaScript files are coming from. Ideally your web server is configured to serve them for you, special 'static' endpoint name: url_for('static', filename='style.css') The file has to be stored on the filesystem as static/style.css. Rendering Templates Generating HTML from within Python is not create.html │ │ ├── index.html │ │ └── update.html │ └── static/ │ └── style.css ├── tests/ │ ├── conftest.py │ ├── data.sql │ ├── test_factory.py │ ├── test_db.py │ ├──0 码力 | 428 页 | 895.98 KB | 1 年前3
Flask Documentation (1.1.x)you. 1.4.5 Static Files Dynamic web applications also need static files. That’s usually where the CSS and JavaScript files are coming from. Ideally your web server is configured to serve them for you, special 'static' endpoint name: url_for('static', filename='style.css') The file has to be stored on the filesystem as static/style.css. 1.4.6 Rendering Templates Generating HTML from within Python is base.html auth/ login.html register.html blog/ create.html index.html update.html static/ style.css tests/ conftest.py data.sql test_factory.py test_db.py test_auth.py test_blog.py venv/ setup.py0 码力 | 291 页 | 1.25 MB | 1 年前3
共 3 条
- 1













