a micro server
Project description
Simple-Starlette
python微服务框架:
- 高性能 : asyncio + Uvicorn 高性能异步非阻塞io,事件循环,多路监听
- 可读性 : 请求与视图解耦,视图与Service解耦,文档与业务解耦
- 开发耗时: 多种基础工具和中间件,类似flask的开发体验
安装使用
1, 使用 pip
直接安装
pip install simple-starlette
2, 源码安装
git clone https://github.com/mapyJJJ/simple-starlette.git
cd simple-starlette
python3 setup.py install
hello world:
from simple_starlette.args import QueryParams
from simple_starlette import SimpleStarlette, Request
from simple_starlette.responses import Response, ResTypeEnum
app = SimpleStarlette(__name__)
@app.route("/test")
class Index:
class SomeQuery(QueryParams):
arg1: int
arg2: int
async def get(self, request: Request, q: SomeQuery): # 定义一个get请求
return Response({"arg1": q.arg1, "arg2": q.arg2}, ResTypeEnum.JSON) # 构造返回json字符串
if __name__ == "__main__":
app.run()
# 测试请求
# curl http://localhost:9091/test?arg1=hello&arg2=world
# response:
# {"arg1":"hello", "arg2":"world"}
查看更多开发使用实例:example usage
basic:
-
apis支持:
cbv/fbv http api
json-rpc
tcp-rpc
grpc-rpc
websocket
-
middleware:
cors
auth jwt+cookie
api-rate-limit
sentry
- ...(compatible all asgi middleware)
-
database:
- relational database:
mysql + sqlalchemy
,postgresql + sqlalchemy
- not noly sql database:
redis
,mongodb
- relational database:
-
cache:
- ttl:
ttlcache
,lruttlcache
- guava_cache:
GuavaCache
- redis-cache
- ttl:
-
async task(定时,延时执行):
simple-async-task
:celery
: 一般架构为(celery+rabbitmq)
-
other:
simple-api-docs
polish query/body params
type hint
各类系统架构template README
LICENSE
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
simple_starlette-3.0.0.tar.gz
(48.8 kB
view hashes)
Built Distribution
Close
Hashes for simple_starlette-3.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d39c109b841db7e853eaa6f9660e918e4f295ef4154c39fcc475aadf8517ab4 |
|
MD5 | 47fc313daa71624cfc0a909f65e8726a |
|
BLAKE2b-256 | c2e60758d1aecbc2e0f9208abc8777e16c12a04da327ae319aed1fe7fbeb9bfe |