Merge branch 'main' of gitee.com:wg123/video-gen into main
This commit is contained in:
@@ -1,10 +1,24 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
import asyncio
|
||||
from redis.asyncio import Redis
|
||||
from app.config import settings
|
||||
from app.utils.redis import get_redis
|
||||
|
||||
router = APIRouter(prefix="/test", tags=["test"])
|
||||
|
||||
|
||||
@router.get("/index")
|
||||
async def test():
|
||||
return {"message": "test","code":200}
|
||||
|
||||
redis = None
|
||||
try:
|
||||
redis = get_redis()
|
||||
await redis.set("test", "123", ex=60)
|
||||
value = await redis.get("test")
|
||||
return {"message": "redis测试成功", "value": value}
|
||||
except Exception as e:
|
||||
if redis:
|
||||
try:
|
||||
await redis.close()
|
||||
except:
|
||||
pass
|
||||
return {"message": f"redis测试失败: {str(e)}"}
|
||||
Reference in New Issue
Block a user