py-summer
一个快速生成 Python Web 项目框架的工具,用户无需考虑后端框架(即支持多后端,目前支持 Flask )。支持自定义生成项目层级结构、接口。内容包含演示代码、测试用例等。
安装
Install and update using pip:
pip install -U py-summer
示例
生成一个新项目
summer create -n test_project -d ./
生成的项目层级结构
│ .gitignore ignore 文件 │ gunicorn.conf gunicorn 配置文件 │ requirements.txt 项目运行所需依赖包 │ server.py 项目入口文件 ├─application application │ │ __init__.py │ │ router.py 路由 │ ├─controller │ │ hello_controller.py controller │ ├─model │ │ hello_model.py model │ └─view │ hello_handler.py handler ├─config │ config.py 配置文件 ├─docker docker 文件夹 │ docker-compose.yml │ start.sh ├─log 日志文件夹 ├─test 测试用例 │ conftest.py │ test_api.py │ test_db.py └─tools 辅助方法 error.py运行项目
python server.py默认监听所有地址, 端口为 8080。测试页可访问 http://127.0.0.1:8080/api/test
生成的项目模块说明
通过上面的示例,我们生成了一个简单的 http web 服务,下面将对生成的目录中各模块做一下介绍,简单的文件已经在目录结构中有说明,这里将不在赘述。
application
这里是 web 应用程序的总目录,里面包含 model/view/controller, 即 web 服务的 MVC 部分,router.py 这里是设置整个项目路由的地方。
config
config 目录是整个工程的配置目录,里面通过类的形式来进行各种环境的配置,通过 application 下的 __init__.py 来导入配置信息。
docker
docker 中是 docker-compose 的配置文件,用来配置项目的部署环境,start.sh 是 docker 容器启动的入口文件。
test
test 这里是项目的单元测试模块,里面有一个 conftest.py 文件来配置测试信息,test_xxx.py 文件是具体的单元测试文件,这里使用 pytest.fixture 打通 server/client 进行测试,测试时无需额外启动 server 即可测试 server 接口。
后续计划
集成 Flask 常用功能模块
- 目前计划集成功能点如下:
启动方式
路由处理
数据库处理
异常处理
常用插件
支持接口根据配置文件自动生成,进一步提高代码规范,开发效率。
Metadata
Release files for py_summer 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_summer-0.0.2.tar.gz | 9.8 kB | Without provenance | Details for py_summer-0.0.2.tar.gz |
Release files / py_summer-0.0.2.tar.gz
| Download URL | py_summer-0.0.2.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd7753a2e06cbe96828ac56dc6df833bde1c29e4e14efa9aff88b5b7d027c0cb
|
|
BLAKE2b-256 checksum How to use checksums |
4abf7b883df67aebcfddc85062f14f7dd554345665670e2c6713306b67d277de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Security for py_summer 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.