diff --git a/app/__init__.py b/app/__init__.py index 7601292..72ccf38 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -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 \ No newline at end of file diff --git a/app/routes/matters.py b/app/routes/matters.py new file mode 100644 index 0000000..bfa13db --- /dev/null +++ b/app/routes/matters.py @@ -0,0 +1,8 @@ +from flask import Blueprint +from ..services import matters + +matter_bp = Blueprint("matter", __name__, "/matter") + +@matter_bp.route("/") +def search_matter(id): + return matters.readMatter(id) \ No newline at end of file diff --git a/app/routes/reactions.py b/app/routes/reactions.py index e6fedde..dee6fab 100644 --- a/app/routes/reactions.py +++ b/app/routes/reactions.py @@ -4,5 +4,5 @@ from ..services import reactions reaction_bp = Blueprint("reaction", __name__, "/reaction") @reaction_bp.route("/") -def search_card(id): +def search_reaction(id): return reactions.readReaction(id) \ No newline at end of file diff --git a/app/services/cards.py b/app/services/cards.py index d224b74..a57f4f9 100644 --- a/app/services/cards.py +++ b/app/services/cards.py @@ -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) diff --git a/app/services/matters.py b/app/services/matters.py index 0bd4d04..6f26ca2 100644 --- a/app/services/matters.py +++ b/app/services/matters.py @@ -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) \ No newline at end of file + 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} \ No newline at end of file diff --git a/app/services/reactions.py b/app/services/reactions.py index ba77511..9762efb 100644 --- a/app/services/reactions.py +++ b/app/services/reactions.py @@ -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) diff --git a/assets/index.json b/resources/assets/index.json similarity index 100% rename from assets/index.json rename to resources/assets/index.json diff --git a/cards/NonMetal/Carbon.json b/resources/cards/NonMetal/Carbon.json similarity index 100% rename from cards/NonMetal/Carbon.json rename to resources/cards/NonMetal/Carbon.json diff --git a/cards/NonMetal/Oxygen.json b/resources/cards/NonMetal/Oxygen.json similarity index 100% rename from cards/NonMetal/Oxygen.json rename to resources/cards/NonMetal/Oxygen.json diff --git a/cards/list.json b/resources/cards/list.json similarity index 100% rename from cards/list.json rename to resources/cards/list.json diff --git a/conditions/Ignite.json b/resources/conditions/Ignite.json similarity index 100% rename from conditions/Ignite.json rename to resources/conditions/Ignite.json diff --git a/matters/Compound/Carbon_Dioxide.json b/resources/matters/Compound/Carbon_Dioxide.json similarity index 100% rename from matters/Compound/Carbon_Dioxide.json rename to resources/matters/Compound/Carbon_Dioxide.json diff --git a/matters/NonMetal/Carbon.json b/resources/matters/NonMetal/Carbon.json similarity index 100% rename from matters/NonMetal/Carbon.json rename to resources/matters/NonMetal/Carbon.json diff --git a/matters/NonMetal/Oxygen.json b/resources/matters/NonMetal/Oxygen.json similarity index 100% rename from matters/NonMetal/Oxygen.json rename to resources/matters/NonMetal/Oxygen.json diff --git a/matters/list.json b/resources/matters/list.json similarity index 100% rename from matters/list.json rename to resources/matters/list.json diff --git a/reactions/Oxidation/CarbonDioxide.json b/resources/reactions/Oxidation/CarbonDioxide.json similarity index 100% rename from reactions/Oxidation/CarbonDioxide.json rename to resources/reactions/Oxidation/CarbonDioxide.json diff --git a/reactions/list.json b/resources/reactions/list.json similarity index 100% rename from reactions/list.json rename to resources/reactions/list.json