Skip to content

Commit

Permalink
手动定义端点名
Browse files Browse the repository at this point in the history
  • Loading branch information
HisAtri committed Oct 27, 2024
1 parent acaddb5 commit 3ae1f39
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions api/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def local_cover_search(title: str, artist: str, album: str):
if res.status_code == 200:
return res.content, 200, {"Content-Type": res.headers['Content-Type']}

@app.route('/cover', methods=['GET'])
@app.route('/cover', methods=['GET'], endpoint='cover_endpoint')
@require_auth_decorator(permission='rw')
@cache.cached(timeout=86400, key_prefix=make_cache_key)
@no_error(exceptions=AttributeError)
Expand All @@ -56,7 +56,7 @@ def cover_api():
abort(500, '服务存在错误,暂时无法查询')


@v1_bp.route('/cover/<path:s_type>', methods=['GET'])
@v1_bp.route('/cover/<path:s_type>', methods=['GET'], endpoint='cover_new_endpoint')
@require_auth_decorator(permission='r')
@cache.cached(timeout=86400, key_prefix=make_cache_key)
@no_error(exceptions=AttributeError)
Expand Down
2 changes: 1 addition & 1 deletion api/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def kv_del(table_name: str, para: dict) -> tuple[bool, any, int]:
except Exception as e:
return False, str(e), 500

@v1_bp.route("/db/<path:table_name>", methods=["POST", "PUT", "GET", "DELETE"])
@v1_bp.route("/db/<path:table_name>", methods=["POST", "PUT", "GET", "DELETE"], endpoint='db_set_endpoint')
@require_auth_decorator(permission='rw')
def db_set(table_name):
"""
Expand Down
6 changes: 3 additions & 3 deletions api/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def download(self):
self.file.write(chunk)


@v1_bp.route("/file/download", methods=["POST"])
@v1_bp.route("/file/download", methods=["POST"], endpoint='file_api_download_endpoint')
@require_auth_decorator(permission='rwd')
def file_api_download():
data = request.json
Expand All @@ -63,7 +63,7 @@ def file_api_download():
return {"error": str(e), "code": 500}, 500


@v1_bp.route('/file/upload', methods=['POST'])
@v1_bp.route('/file/upload', methods=['POST'], endpoint='upload_file_endpoint')
@require_auth_decorator(permission='rwd')
def upload_file():
if 'file' not in request.files:
Expand Down Expand Up @@ -95,7 +95,7 @@ def upload_file():
return {"code": 200}, 200


@v1_bp.route('/file/list', methods=['GET'])
@v1_bp.route('/file/list', methods=['GET'], endpoint='list_file_endpoint')
@require_auth_decorator(permission='rwd')
def list_file():
path = request.args.get('path', os.getcwd())
Expand Down
8 changes: 4 additions & 4 deletions api/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def read_file_with_encoding(file_path: str, encodings: list[str]):
return None


@app.route('/lyrics', methods=['GET'])
@v1_bp.route('/lyrics/single', methods=['GET'])
@app.route('/lyrics', methods=['GET'], endpoint='lyrics_endpoint')
@v1_bp.route('/lyrics/single', methods=['GET'], endpoint='lyrics_endpoint')
@require_auth_decorator(permission='r')
@cache.cached(timeout=86400, key_prefix=make_cache_key)
def lyrics():
Expand Down Expand Up @@ -59,8 +59,8 @@ def lyrics():
return "Lyrics not found.", 404


@app.route('/jsonapi', methods=['GET'])
@v1_bp.route('/lyrics/advance', methods=['GET'])
@app.route('/jsonapi', methods=['GET'], endpoint='jsonapi_endpoint')
@v1_bp.route('/lyrics/advance', methods=['GET'], endpoint='jsonapi_endpoint')
@require_auth_decorator(permission='r')
@cache.cached(timeout=86400, key_prefix=make_cache_key)
def lrc_json():
Expand Down
4 changes: 2 additions & 2 deletions api/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def serve_file(filename):
abort(404)


@app.route('/file/<path:filename>')
@v1_bp.route('/file/<path:filename>')
@app.route('/file/<path:filename>', endpoint='file_viewer_endpoint')
@v1_bp.route('/file/<path:filename>', endpoint='file_viewer_endpoint')
@require_auth_decorator(permission='r')
def file_viewer(filename):
"""
Expand Down
4 changes: 2 additions & 2 deletions api/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from mod.dev.debugger import debugger


@app.route('/tag', methods=['POST', 'PUT'])
@app.route('/confirm', methods=['POST', 'PUT'])
@app.route('/tag', methods=['POST', 'PUT'], endpoint='set_tag_endpoint')
@app.route('/confirm', methods=['POST', 'PUT'], endpoint='set_tag_endpoint')
@require_auth_decorator(permission='rw')
def set_tag():
music_data = request.json
Expand Down

0 comments on commit 3ae1f39

Please sign in to comment.