Skip to main content

一款web协程框架

Project description

CheeseAPI

介绍

一款协程友好的web框架,它有大部分框架都有的功能,以及它的特点:

  1. 插件支持,更可塑的事件处理。

  2. 类Django的项目结构。

  3. Websocket支持。

  4. 支持部分配置项动态设置。

目前项目仍处于开发阶段,未来期望提供的功能:

  1. 对于请求更完善的处理。

  2. 更好的架构设计以及更快的算法处理。

  3. 更多的插件。

  4. 提供命令,以方便管理项目。

  5. 自定义的工作目录。

  6. 更多的配置选项。

安装

目前仅支持linux python3.11,这里也推荐将python升级到3.11。

pip install CheeseAPI

使用

简单的示例

目前只支持在当前工作目录下运行。

创建一个启动入口:

# File path: ./app.py

from CheeseAPI import app, Response

'''
路由装饰器装饰的函数参数是可选的,如果你需要获取request,则:
async def test(request):
    ...
即可,其他参数都是动态获取的。
'''
@app.route.get('/')
async def test():
    return Response('您好,这里是CheeseAPI!')

if __name__ == '__main__':
    app.run() # 默认的启动地址:'0.0.0.0',默认的启动端口:5214

运行app.py,可以看到打印了一些基础信息,当当前代码的最后一行启动时,代表系统已经可以访问:

$ python app.py
(STARTING) 2023-08-24 12:20:56.933161 > The master process 700506 started
(STARTING) 2023-08-24 12:20:56.934117 > Workspace information:
    CheeseAPI: /xxx/CheeseAPI/CheeseAPI
    Base: /xxx/CheeseAPI
(STARTING) 2023-08-24 12:20:56.934274 > Server information:
    Host: 0.0.0.0
    Port: 5214
    Workers: 1
(STARTING) 2023-08-24 12:20:56.934619 > Local Modules:
    CheeseAPI
(LOADED) 2023-08-24 12:20:56.937603 > The local modules are loaded, which takes 0.002867 seconds
(DEBUG) 2023-08-24 12:20:56.938326 > The subprocess 700506 started
(STARTING) 2023-08-24 12:20:56.939158 > The server started on http://0.0.0.0:5214
(STARTING) 2023-08-24 12:20:56.939279 > The server startup takes 0.006139 seconds

使用ctrl + ckill <pid>杀死进程,会打印完剩下的内容:

(DEBUG) 2023-08-24 12:29:19.061431 > The 701056 subprocess stopped
(ENDING) 2023-08-24 12:29:19.062018 > The server runs for a total of 11.326843 seconds
(ENDING) 2023-08-24 12:29:19.062144 > The master process 701056 stopped

项目结构

CheeseAPI采用类Django的结构:

| - User
    | - model.py
    | - api.py
    | - service.py
| - Permission
    | - model.py
    | - api.py
    | - service.py
| - app.py

在项目根目录下的文件夹(不包括隐藏文件夹)内的文件会在项目启动时自动导入。

在CheeseAPI中并没有强制规定文件名与其代码的关联性,但建议的文件命名方式如下:

文件名 备注
model.py 模型类
api.py api接口
service.py 业务逻辑实现

更多...

1. 生命周期

2. App

2.1 Workspace

2.2 Server

2.3 Cors

2.4 Handle

3. Route

4. Request

5. Response

6. Websocket

7. Module

8. Signal

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CheeseAPI-0.1.6.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

CheeseAPI-0.1.6-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file CheeseAPI-0.1.6.tar.gz.

File metadata

  • Download URL: CheeseAPI-0.1.6.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for CheeseAPI-0.1.6.tar.gz
Algorithm Hash digest
SHA256 473dbcc48f1d64d530b934eaa645611e0ebd81d3611e654b8f3adfee0dee97db
MD5 5d9b6cafac7a695c9f8a7da446e6d9d7
BLAKE2b-256 986da5093a297ea86a4c4578fbb3c3580ee98035ea376bf3977ce93308a81bfa

See more details on using hashes here.

File details

Details for the file CheeseAPI-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: CheeseAPI-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for CheeseAPI-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 dd8d744c6ecf42f91356f3133489417c703ae1ab390f9c59a116e391d803de92
MD5 af842d8171f0e73514215b1fd02020d7
BLAKE2b-256 aa33a08a144334e2d94a24c4b1f3f9e3c3a3f45cd672fe18d4f0864f855eed6a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page