feat: 实现反应和卡牌信息读取,并编写了测试用卡牌和反应

This commit is contained in:
2026-01-05 09:30:43 +08:00
parent b8b7c6e889
commit 09cbbf9eea
16 changed files with 96 additions and 8 deletions
+4 -1
View File
@@ -10,6 +10,9 @@ def create_app(config_class='config.DevelopmentConfig'):
app.register_blueprint(page_bp)
from app.routes.cards import card_bp
app.register_blueprint(card_bp)
app.register_blueprint(card_bp, url_prefix="/card")
from app.routes.reactions import reaction_bp
app.register_blueprint(reaction_bp, url_prefix="/reaction")
return app
+8
View File
@@ -0,0 +1,8 @@
from flask import Blueprint
from ..services import reactions
reaction_bp = Blueprint("reaction", __name__, "/reaction")
@reaction_bp.route("/<id>")
def search_card(id):
return reactions.readReaction(id)
+8 -1
View File
@@ -8,4 +8,11 @@ def readCardList() -> dict:
return result
def readCard(id: str):
return readCardList().get(id, f"No Card {id}")
path = readCardList().get(id, -1)
if (path == -1):
return {"message": f"No Card {id}"}
with open(f"cards/{path}.json", "r", encoding="utf8") as f:
text = f.read()
result = json.loads(text)
return {"message": "OK", "content": result}
+8 -1
View File
@@ -8,4 +8,11 @@ def readReactionList() -> dict:
return result
def readReaction(id: str):
return readReactionList().get(id, -1)
path = readReactionList().get(id, -1)
if (path == -1):
return {"message": f"No Reaction {id}"}
with open(f"reactions/{path}.json", "r", encoding="utf8") as f:
text = f.read()
result = json.loads(text)
return {"message": "OK", "content": result}