上传文件至「/」

This commit is contained in:
2026-09-19 14:42:24 +08:00
parent 71d78ef4c7
commit 60999c332b
5 changed files with 92 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
from fastapi import Response,Request
from time import time
async def fun_ip(r,n):
print('获取客户端的来访ip:',r.client.host)
if r.client.host not in ['192.168.5.18','192.168.5.6']:
respons = await n(r)
return respons
return Response(status_code=403,content='Not have Permission!')
async def fun_time(r:Request,n):
start_time = time() # 记录开始的时间
respons = await n(r) # 接口执行
end_time = time() # 记录结束的时间
sss = end_time - start_time
print( f'接口响应耗时:{sss}s' )
respons.headers["Time"] = str(sss) # 添加到响应头里,必须是字符串
return respons