feat: 增加description.py,修复中文问题
This commit is contained in:
@@ -3,6 +3,7 @@ from flask import Flask
|
||||
def create_app(config_class='config.Config'):
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(config_class)
|
||||
app.json.ensure_ascii = False # type: ignore
|
||||
|
||||
# 注册蓝图
|
||||
from app.routes.pages import page_bp
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
'''
|
||||
资源文件读取路由
|
||||
'''
|
||||
from flask import Blueprint, send_file
|
||||
from flask import Blueprint, send_file, jsonify
|
||||
from ..utils import assets
|
||||
|
||||
asset_bp = Blueprint("asset", __name__, "/asset")
|
||||
|
||||
@asset_bp.route("/list")
|
||||
def asset_list():
|
||||
return assets.readAssetsList()
|
||||
return jsonify(assets.readAssetsList())
|
||||
|
||||
@asset_bp.route("/pic/<id>")
|
||||
def find_pic(id: str):
|
||||
|
||||
+3
-3
@@ -1,15 +1,15 @@
|
||||
'''
|
||||
卡牌定义文件读取路由
|
||||
'''
|
||||
from flask import Blueprint
|
||||
from flask import Blueprint, jsonify
|
||||
from ..utils import cards
|
||||
|
||||
card_bp = Blueprint("card", __name__, "/card")
|
||||
|
||||
@card_bp.route("/list")
|
||||
def card_list():
|
||||
return cards.readCardList()
|
||||
return jsonify(cards.readCardList())
|
||||
|
||||
@card_bp.route("/id/<id>")
|
||||
def search_card(id):
|
||||
return cards.readCard(id)
|
||||
return jsonify(cards.readCard(id))
|
||||
@@ -1,15 +1,15 @@
|
||||
'''
|
||||
物质定义文件读取路由
|
||||
'''
|
||||
from flask import Blueprint
|
||||
from flask import Blueprint, jsonify
|
||||
from ..utils import matters
|
||||
|
||||
matter_bp = Blueprint("matter", __name__, "/matter")
|
||||
|
||||
@matter_bp.route("/list")
|
||||
def matter_list():
|
||||
return matters.readMatterList()
|
||||
return jsonify(matters.readMatterList())
|
||||
|
||||
@matter_bp.route("/id/<id>")
|
||||
def search_matter(id):
|
||||
return matters.readMatter(id)
|
||||
return jsonify(matters.readMatter(id))
|
||||
+7
-2
@@ -2,9 +2,14 @@
|
||||
网页路由
|
||||
'''
|
||||
from flask import Blueprint, jsonify
|
||||
from ..utils import index
|
||||
|
||||
page_bp = Blueprint("page", __name__, "/")
|
||||
|
||||
@page_bp.route("/")
|
||||
def index():
|
||||
return jsonify({"code": "200", "message": "Service normal"})
|
||||
def index_page():
|
||||
return jsonify({"code": "200", "message": "Service normal"})
|
||||
|
||||
@page_bp.route("/index")
|
||||
def description():
|
||||
return jsonify(index.readIndex())
|
||||
@@ -1,23 +1,23 @@
|
||||
'''
|
||||
反应定义文件读取路由
|
||||
'''
|
||||
from flask import Blueprint
|
||||
from flask import Blueprint, jsonify
|
||||
from ..utils import reactions
|
||||
|
||||
reaction_bp = Blueprint("reaction", __name__, "/reaction")
|
||||
|
||||
@reaction_bp.route("list")
|
||||
def reaction_list():
|
||||
return reactions.readReactionList()
|
||||
return jsonify(reactions.readReactionList())
|
||||
|
||||
@reaction_bp.route("/match")
|
||||
def match_list():
|
||||
return reactions.readMatchList()
|
||||
return jsonify(reactions.readMatchList())
|
||||
|
||||
@reaction_bp.route("/id/<id>")
|
||||
def search_reaction(id):
|
||||
return reactions.readReaction(id)
|
||||
return jsonify(reactions.readReaction(id))
|
||||
|
||||
@reaction_bp.route("/match/<id>")
|
||||
def select_reaction(id):
|
||||
return reactions.selectReaction(id)
|
||||
return jsonify(reactions.selectReaction(id))
|
||||
@@ -0,0 +1,12 @@
|
||||
'''
|
||||
读取 description.json 的内容
|
||||
'''
|
||||
import json
|
||||
|
||||
def readIndex() -> dict:
|
||||
|
||||
with open("resources/description.json", "r", encoding="utf8") as f:
|
||||
text = f.read()
|
||||
result = json.loads(text)
|
||||
|
||||
return result
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Offical Example",
|
||||
"author": "Paper Chemis Community Team",
|
||||
"uuid": "6b3d2702c1c345499fc8617d664b3627"
|
||||
}
|
||||
Reference in New Issue
Block a user