From 80da8a5485aecf6305c32eec5cc760c7abc01843 Mon Sep 17 00:00:00 2001 From: MarkusJoe Date: Sun, 2 Oct 2022 17:30:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=BD=BF?= =?UTF-8?q?=E7=94=A8api=E6=9F=A5=E8=AF=A2=E4=B8=BB=E9=A2=98=E6=97=B6?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/view.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/api/view.py b/src/api/view.py index 2b330e1..2132572 100644 --- a/src/api/view.py +++ b/src/api/view.py @@ -6,9 +6,11 @@ # @File Name: view.py +import os from src.api import api from src.db import Database from fastapi.responses import FileResponse +from fastapi.responses import JSONResponse @api.get('/query/{name}') @@ -19,6 +21,8 @@ async def query(name: str): @api.get('/query-all/') async def query_all(limit: int = 30): + if os.getenv('c_not_full'): + return JSONResponse({'code': -200, 'msg': 'Redis Database do not support this action'}) data = Database().query_all()[:limit] result = {} for i in data: @@ -33,8 +37,5 @@ async def export(): @api.get('/query-theme/{name}') async def query_theme(name: str): - themes = [] - for i in range(10): - data = Database().query_image(name + '/' + str(i))[0] - themes.append(data) - return themes + data = Database().query_image(name) + return data