mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
feat: 优化代码
This commit is contained in:
parent
9e31f3beb1
commit
ef38fa3c9f
7
main.py
7
main.py
@ -29,6 +29,7 @@ from common import utils
|
||||
from common import lxsecurity
|
||||
from common import Httpx
|
||||
from apis import SongURL
|
||||
import traceback
|
||||
Httpx.checkcn()
|
||||
|
||||
@app.route('/')
|
||||
@ -50,7 +51,11 @@ async def handle(method, source, songId, quality):
|
||||
return utils.format_dict_json({"code": 1, "msg": "lxm请求头验证失败", "data": None}), 403
|
||||
|
||||
if method == 'url':
|
||||
return utils.format_dict_json(await SongURL(source, songId, quality))
|
||||
try:
|
||||
return utils.format_dict_json(await SongURL(source, songId, quality))
|
||||
except Exception as e:
|
||||
logger.error(traceback.format_exc())
|
||||
return utils.format_dict_json({'code': 4, 'msg': '内部服务器错误', 'data': None}), 500
|
||||
else:
|
||||
return utils.format_dict_json({'code': 6, 'msg': '未知的请求类型: ' + method, 'data': None}), 400
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user