feat: 实现物质查询,调整项目结构
This commit is contained in:
@@ -14,5 +14,8 @@ def create_app(config_class='config.DevelopmentConfig'):
|
||||
|
||||
from app.routes.reactions import reaction_bp
|
||||
app.register_blueprint(reaction_bp, url_prefix="/reaction")
|
||||
|
||||
from app.routes.matters import matter_bp
|
||||
app.register_blueprint(matter_bp, url_prefix="/matter")
|
||||
|
||||
return app
|
||||
@@ -0,0 +1,8 @@
|
||||
from flask import Blueprint
|
||||
from ..services import matters
|
||||
|
||||
matter_bp = Blueprint("matter", __name__, "/matter")
|
||||
|
||||
@matter_bp.route("/<id>")
|
||||
def search_matter(id):
|
||||
return matters.readMatter(id)
|
||||
@@ -4,5 +4,5 @@ from ..services import reactions
|
||||
reaction_bp = Blueprint("reaction", __name__, "/reaction")
|
||||
|
||||
@reaction_bp.route("/<id>")
|
||||
def search_card(id):
|
||||
def search_reaction(id):
|
||||
return reactions.readReaction(id)
|
||||
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
|
||||
def readCardList() -> dict:
|
||||
with open("cards/list.json", "r", encoding="utf8") as f:
|
||||
with open("resources/cards/list.json", "r", encoding="utf8") as f:
|
||||
text = f.read()
|
||||
result = json.loads(text)
|
||||
|
||||
@@ -11,7 +11,7 @@ def readCard(id: str):
|
||||
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:
|
||||
with open(f"resources/cards/{path}.json", "r", encoding="utf8") as f:
|
||||
text = f.read()
|
||||
result = json.loads(text)
|
||||
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import json
|
||||
|
||||
def readMatterList() -> dict:
|
||||
with open("matters/list.json", "r", encoding="utf8") as f:
|
||||
with open("resources/matters/list.json", "r", encoding="utf8") as f:
|
||||
text = f.read()
|
||||
result = json.loads(text)
|
||||
|
||||
return result
|
||||
|
||||
def readMatter(id: str):
|
||||
return readMatterList().get(id, -1)
|
||||
path = readMatterList().get(id, -1)
|
||||
if (path == -1):
|
||||
return {"message": f"No Matter {id}"}
|
||||
with open(f"resources/matters/{path}.json", "r", encoding="utf8") as f:
|
||||
text = f.read()
|
||||
result = json.loads(text)
|
||||
|
||||
return {"message": "OK", "content": result}
|
||||
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
|
||||
def readReactionList() -> dict:
|
||||
with open("reactions/list.json", "r", encoding="utf8") as f:
|
||||
with open("resources/reactions/list.json", "r", encoding="utf8") as f:
|
||||
text = f.read()
|
||||
result = json.loads(text)
|
||||
|
||||
@@ -11,7 +11,7 @@ def readReaction(id: str):
|
||||
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:
|
||||
with open(f"resources/reactions/{path}.json", "r", encoding="utf8") as f:
|
||||
text = f.read()
|
||||
result = json.loads(text)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user