diff --git a/docs/book/4/snippets/c4.md b/docs/book/4/snippets/c4.md deleted file mode 100644 index 117d6bb..0000000 --- a/docs/book/4/snippets/c4.md +++ /dev/null @@ -1,53 +0,0 @@ -# 第 4 章:表单 - - -## 使用 Bootstrap-Flask 渲染表单 - -base.html - -```html - - - - - - HelloFlask - {% block styles %} - - {% endblock %} - - - {% block content %}{% endblock %} - - -``` - -index.html - -```html -{% extends 'base.html' %} -{% from 'bootstrap5/form.html' import render_field, render_form, render_form_row %} - -{% block content %} -
-

Render Form with Bootstrap-Flask

-

1. render_field

-
- {{ form.csrf_token }} - {{ render_field(form.username) }} - {{ render_field(form.password) }} - {{ render_field(form.remember) }} - {{ render_field(form.submit) }} -
-

1. render_form

- {{ render_form(form) }} -

1. render_form_row

-
- {{ form.csrf_token }} - {{ render_form_row([form.username, form.password]) }} - {{ render_field(form.remember) }} - {{ render_field(form.submit) }} -
-
-{% endblock %} -``` diff --git a/docs/book/4/snippets/index.md b/docs/book/4/snippets/index.md deleted file mode 100644 index da3b188..0000000 --- a/docs/book/4/snippets/index.md +++ /dev/null @@ -1,15 +0,0 @@ -# 代码片段 - -《Flask Web 开发实战(第 2 版)》第 1~7 章出现的所有代码片段会放到这里,方便读者直接复制到本地运行测试。 - -点击左侧的章节导航访问对应的代码片段。 - -为了运行这些示例,建议在本地为每一章创建一个这样的文件目录结构: - -```text -- c1/ - - templates/ - - static/ - - app.py - - .flaskenv -``` diff --git a/mkdocs.yml b/mkdocs.yml index e23bae3..c3aa2e0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -59,14 +59,6 @@ nav: - 第 2 版(2024): - 主页↗: https://helloflask.com/book/4 - 示例程序: book/4/example.md - - 代码片段: - - 主页: book/4/snippets/index.md - - 第 1 章:初识 Flask: book/4/snippets/c1.md - - 第 2 章:Flask 与 HTTP: book/4/snippets/c2.md - - 第 3 章:模板和静态文件: book/4/snippets/c3.md - - 第 4 章:表单: book/4/snippets/c4.md - - 第 5 章:数据库: book/4/snippets/c5.md - - 第 6 章:电子邮件: book/4/snippets/c6.md - Flask 入门教程: - 主页↗: https://helloflask.com/book/3 - GitHub↗: https://github.com/helloflask/flask-tutorial