最近尝试着把一个拥有12个版块(每个版块大概有10个子版块),业务类型大概有9种的业务负责的网站从 ThinkPHP 迁移重构至 基于 Python 的 Flask
应该在 Flask 框架中如何处理以下这些问题:
- 目录结构
- 模块分割
- 代码文件的分布
- 构建内部 APIs
- 插件
PS 顺便吐槽一下前辈们留下的 ThinkPHP 代码 ~
PS 非0基础,完成过一些小的 Flask 项目。但没有做过大型项目。
june 应该是mvc的其实也不是很适合做大型项目,个人观点哈! 你可以参考Django的目录结构。还有,有个开源的flask框架,和django的目录结构差不多,用bluesprint 来组织的,名字忘记了,你在github上search一下,蛮好的。
还是划分模块吧。
可以参考 https://github.com/eugenkiss/Simblin 。
好吧,又是我,参考作者的建议 https://github.com/mitsuhiko/flask/wiki/Large-app-how-to
推荐一个项目 june https://github.com/lepture/june
why not use Flask's Blueprint ?
$ tree shovel -d
shovel
├── migrations
│ └── versions
└── shovel
├── admin
├── api
├── static
│ ├── css
│ │ └── plugins
│ │ └── dataTables
│ ├── images
│ └── js
│ └── plugins
│ ├── dataTables
│ └── metisMenu
├── templates
│ └── admin
├── translations
│ └── zh
│ └── LC_MESSAGES
└── web
20 directories