| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- 共享库入口文件 (.so / .pyd)
- 暴露 Python 级别的函数供外部(如 Node.js / Vue3)调用。
- """
- import json
- import base64
- from license_checker import verify_license
- # 延迟导入核心业务逻辑,确保先验证 License
- def _check_auth():
- if not verify_license():
- raise PermissionError("License verification failed. Please provide a valid license.lic and public_key.pem file.")
- def get_path():
- """对应原 api_test.py 中的 getpath"""
- _check_auth()
- import data_clean as dc
- return_path = str(dc.result_main())
- return json.dumps({'obj': return_path}, ensure_ascii=False)
- def load_data(b64_json_data):
- """对应原 api_test.py 中的 loaddata"""
- _check_auth()
- import data_clean as dc
- data = json.loads(base64.b64decode(b64_json_data).decode("utf-8"))
- return_list = dc.data_analyse(data)
- return json.dumps(return_list, ensure_ascii=False)
- def history_data(b64_json_data):
- """对应原 api_test.py 中的 historydata"""
- _check_auth()
- import data_clean as dc
- data = json.loads(base64.b64decode(b64_json_data).decode("utf-8"))
- return_list = dc.history_data(data)
- return json.dumps(return_list, ensure_ascii=False)
- def delete_data(b64_json_data):
- """对应原 api_test.py 中的 deletedata"""
- _check_auth()
- import data_clean as dc
- data = json.loads(base64.b64decode(b64_json_data).decode("utf-8"))
- return_path = dc.delete_data(data)
- return json.dumps(return_path, ensure_ascii=False)
|