Skip to content

Commit

Permalink
Merge pull request #295 from greyli/models
Browse files Browse the repository at this point in the history
Update examples for chapter 5
  • Loading branch information
greyli authored Jun 25, 2024
2 parents 8f1f46c + a7c1dc1 commit f7db4ab
Show file tree
Hide file tree
Showing 444 changed files with 50,998 additions and 108 deletions.
53 changes: 0 additions & 53 deletions docs/book/4/snippets/c4.md

This file was deleted.

15 changes: 0 additions & 15 deletions docs/book/4/snippets/index.md

This file was deleted.

18 changes: 14 additions & 4 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

在运行示例程序之前,确保你已经把仓库克隆到本地,并完成创建虚拟环境,安装依赖等操作,详见[获取示例程序](https://docs.helloflask.com/installation)

每一章的示例程序放在 examples 目录下不同的子文件内,以第 1 章示例程序为例,你需要把工作目录切换到 examples/c1 目录内,然后执行 `flask run` 启动程序:
每一章的示例程序放在 examples 目录下不同的子文件内,以第 1 章示例程序为例,你需要把工作目录切换到 examples/ch1 目录内,然后执行 `flask run` 启动程序:

```
cd examples/c1
cd examples/ch1
flask run
```

Expand All @@ -20,8 +20,18 @@ pdm run flask run
通过切换到不同的示例程序目录来运行不同章节的示例程序。比如,下面的命令将会运行第 4 章的示例程序:

```
cd examples/c4
cd examples/ch4
flask run # 或 pdm run flask run
```

*在书中相应位置会包含运行实例程序的提示。*
所有示例程序和章节对应关系如下:

- 第 1 章:`ch1`
- 第 2 章:`ch2`
- 第 3 章:`ch3`
- 第 4 章:`ch4`
- 第 5 章:`ch5``notebook`
- 第 7 章:`longtalk``album`
- 第 12 章:`assets``cache`

*在书中相应位置会包含运行示例程序的提示。*
File renamed without changes.
44 changes: 44 additions & 0 deletions examples/assets/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from flask import Flask, render_template
from flask_assets import Environment, Bundle
from flask_ckeditor import CKEditor


app = Flask(__name__)
app.secret_key = 'dev key'

assets = Environment(app)
ckeditor = CKEditor(app)

css = Bundle('css/bootstrap.min.css',
'css/bootstrap.css',
'css/dropzone.min.css',
'css/jquery.Jcrop.min.css',
'css/style.css',
filters='cssmin', output='gen/packed.css')

js = Bundle('js/jquery.min.js',
'js/popper.min.js',
'js/bootstrap.min.js',
'js/bootstrap.js',
'js/moment-with-locales.min.js',
'js/dropzone.min.js',
'js/jquery.Jcrop.min.js',
filters='jsmin', output='gen/packed.js')

assets.register('js_all', js)
assets.register('css_all', css)


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


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


@app.route('/bar')
def optimized():
return render_template('optimized.html')
1,469 changes: 1,469 additions & 0 deletions examples/assets/static/ckeditor/CHANGES.md

Large diffs are not rendered by default.

Loading

0 comments on commit f7db4ab

Please sign in to comment.