Files
YG-Rules/app/routes/schema.py

35 lines
928 B
Python

"""Schema 接口。"""
from __future__ import annotations
from flask import Blueprint, request
from app.utils.response import error, success
from app.utils.schema_storage import SchemaStorage
schema_bp = Blueprint("schema", __name__)
@schema_bp.get("/api/schema")
def get_schema():
return success(SchemaStorage().get(), message="查询成功")
@schema_bp.get("/api/schema/status")
def schema_status():
return success(SchemaStorage().status(), message="查询成功")
@schema_bp.post("/api/schema/upload")
def upload_schema():
file = request.files.get("file")
if not file:
return error("上传失败:缺少上传文件", 400)
data = SchemaStorage().save("file", file.stream.read(), file.filename)
return success(data, message="上传成功")
@schema_bp.delete("/api/schema")
def delete_schema():
return success({"deleted": SchemaStorage().delete_file()}, message="删除成功")