上传文件至「/」

This commit is contained in:
2026-09-19 14:42:25 +08:00
parent 6085ce85fe
commit 4818d2bfcf
5 changed files with 71 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import time
from fastapi import FastAPI, Response
app = FastAPI()
@app.middleware('http')
async def middl(req,next):
print('获取客户端的请求地址',req.client.host)
if req.client.host not in ['192.168.1.26','192.168.1.40','192.168.1.51']:
r = await next(req)
return r
else:
return Response(content='不可访问')
@app.middleware('http')
async def middl1(req,next):
a=time.time()
r = await next(req)
b=time.time()
print(f'执行的时间是{b-a}')
return r