Skip to content

Commit 2d9fe33

Browse files
committed
add flask-26
1 parent df98d09 commit 2d9fe33

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Flask-26-executor/app.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@
77

88

99
def send_email(recipient, subject, body):
10-
# Magic to send an email
10+
# 模拟邮件发送动作
11+
print('send mail.')
1112
return True
1213

1314

15+
def callback(future):
16+
print('callback')
17+
18+
1419
@app.route('/signup')
1520
def signup():
16-
# Do signup form
17-
executor.submit(send_email, recipient, subject, body)
21+
executor.add_default_done_callback(callback)
22+
executor.submit(send_email, "test@gmail.com", "subject", "body")
23+
return "signup done."
24+
25+
26+
if __name__ == '__main__':
27+
app.run('0.0.0.0', debug=True, port=5000)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424
22. [在浏览器中播放rtsp实时流](https://xugaoxiang.com/2020/11/12/flask-22-opencv-rtsp/)
2525
23. [简单异步任务](https://xugaoxiang.com/2020/11/16/flask-23-threadpoolexecutor/)
2626
24. [http请求转发](https://xugaoxiang.com/2020/11/24/flask-24-http-proxy/)
27-
25. [接收多文件](https://xugaoxiang.com/2021/05/20/flask-25-receive-multiple-files/)
27+
25. [接收多文件](https://xugaoxiang.com/2021/05/20/flask-25-receive-multiple-files/)
28+
25. [flask-executor](https://xugaoxiang.com/2021/12/27/flask-26-flask-executor/)

0 commit comments

Comments
 (0)