ViboraPython 异步网络框架
Vibora 是一个 Python 异步网络框架(Python 3.6+),目前正在开发中,处于 alpha 阶段。
按作者的说法,Vibora 翻译成中文就是“毒蛇”的意思。
服务器端功能
-
Schemas 引擎 (比 marshmallow 快 50 倍,支持异步)
-
Nested Blueprints / Domain Based Routes / Components
-
Connection Reaper / 可自修复的 Workers
-
支持回话 (files, Redis, Memcache)
-
Streaming
-
Websockets
-
缓存工具
-
异步模板引擎(热重载、深继承)
-
完整的流量定制
-
静态文件(Smart Cache, Range, LastModified, ETags)
-
完整的测试框架
-
输入提示
客户端功能
-
最快的 Python HTTP 客户端
-
Streaming MultipartForms (Inspired by: https://github.com/requests/requests/issues/1584)
-
Rate Limiting / Retries mechanisms
-
Websockets
-
Keep-Alive & Connection Pooling
-
Sessions with cookies persistence
-
Basic/digest Authentication
-
Transparent Content Decoding
服务器端示例代码
from vibora import Vibora, Request from vibora.responses import JsonResponse app = Vibora() @app.route('/') async def home(request: Request): return JsonResponse({'hello': 'world'}) if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=8000)
客户端示例代码
import asyncio from vibora import client async def hello_world(): response = await client.get('https://google.com/') print(f'Content: {response.content}') print(f'Status code: {response.status_code}') if __name__ == '__main__': loop = asyncio.get_event_loop() loop.run_until_complete(hello_world())
文档
评论