单个脚本编写小型 Web应用很方便,但是伸缩性不好,难以扩展和维护。
本文介绍一种常见的前后端分离项目的结构设计。
|- your_project|- app|- commons # 公共方法|- config # 配置文件|- config_live.json|- config_local.json|- enum # 配置枚举值|- business_enum.py|- models # 模型类|- __init__.py # 将models 这个文件夹变成 Python module|- student|- student.py|- resources # 接口|- __init__.py|- student|- __init__.py|- student_api.py|- service # view logic,视图逻辑,主要封装业务逻辑处理|- __init__.py|- student.py|- utils # 工具库|- __init__.py|- tools.py|- dockerfiles # 容器化部署|- Dockerfile|- requirements.txt
/
