【Python】FastAPI

1,简介
    FastAPI是一种现代,快速(高性能)的Web框架,用于基于标准Python类型提示使用Python 3.6+构建API。

2,安装

pip install fastapi
pip install uvicorn

3,应用
3.1 main.py

from fastapi import FastAPI

app = FastAPI()

@app.get("/index")
async def index():
    return "hello world"

3.2 运行

uvicorn main:app --reload

3.3 fps分析

ab -c 10 -n 10000 http://127.0.0.1:8000
部分信息
Concurrency Level:      10
Time taken for tests:   1.761 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      1380000 bytes
HTML transferred:       130000 bytes
Requests per second:    5679.08 [#/sec] (mean)
Time per request:       1.761 [ms] (mean)
Time per request:       0.176 [ms] (mean, across all concurrent requests)
Transfer rate:          765.34 [Kbytes/sec] received

fps: 5679.08 [#/sec] (mean)

4,参考文档
https://www.cnblogs.com/mazhiyong/p/12807660.html
https://blog.csdn.net/Hiking_Yu/article/details/104145437

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值