上传文件至「/」
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user