更好的程序结构

Better Structure

当前的框架是有几个模板
1.试图函数 2.模板 3.表格
通常这种架构适合小型应用程序

对于大的程序,通常是按功能模块来分(模块重用)
使用者验证子系统
错误子系统
应用子系统
以及程序启动方法

一方面是为了功能模块重用
第二个方面是为了方便测试

蓝图

蓝图实现了应用的模块化,使用蓝图让应用层次清晰,开发者更容易的开发和维护项目。蓝图通常作用于相同的URL前缀。

错误处理蓝图

def send_email(subject, sender, recipients, text_body, html_body):
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    msg.html = html_body
    Thread(target=send_async_email, args=(app, msg)).start()
#    current_app._get_current_object() expression extracts the #actual application instance from inside the proxy object

包下载管理

pip freeze > requirements.txt#更新requirements.txt包文件
pip install -r requirements.txt#下载并安装requirments.txt里头的包

pip freeze command will dump all the packages that are installed on your virtual environment in the correct format for the requirements.txt file

posted @ 2018-03-29 18:28  blog_hfg  阅读(135)  评论(0)    收藏  举报