为MVC模式组织我的Python项目

2 投票
1 回答
1348 浏览
提问于 2025-04-17 02:21

我刚接触Python,遇到了整理代码文件的问题。

我想做的事情是:

./
 /views
        index.html  // Django files

 /controlers
        main.py

 /models
        Greeting.py  // I take the same classe exemple of Google App Engine Website
 /libs
        xxx.py //some Lib and tools classes  
 /static
        /js
        /css
        /images

但我真正的问题是,文件结构在Python环境中是否正确?

1 个回答

1

是的,你的结构是可以的。如果你觉得我的例子有用,这里是我如何组织一个较小的应用程序的方式:

.
├── app.yaml
├── conf.py
├── main.py
├── model.py
├── static
│   ├── 1.gif
│   ├── 2.gif
│   ├── 3.gif
│   ├── 4.gif
│   ├── anim.gif
│   ├── main.css
│   ├── main.js
└── templates
    ├── base.html
    ├── error.html
    ├── info.html
    ├── upload.html
    ├── user.html
    └── welcome.html

撰写回答