38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
# license_module.py
|
|
import requests
|
|
|
|
# 发送请求到 /api/license/use 接口
|
|
def use_license():
|
|
target_url = 'http://127.0.0.1:5288/api/license/use'
|
|
try:
|
|
response = requests.post(target_url) # 使用 POST 请求
|
|
if response.status_code == 200:
|
|
return response.json() # 返回响应数据
|
|
else:
|
|
return {'error': 'Failed to fetch data from target API', 'status_code': response.status_code}
|
|
except Exception as e:
|
|
return {'error': str(e)} # 捕获异常并返回错误信息
|
|
|
|
# 发送请求到 /api/license/check 接口
|
|
def check_license():
|
|
target_url = 'http://127.0.0.1:5288/api/license/check'
|
|
try:
|
|
response = requests.get(target_url) # 使用 GET 请求
|
|
if response.status_code == 200:
|
|
return response.json() # 返回响应数据
|
|
else:
|
|
return {'error': 'Failed to fetch data from target API', 'status_code': response.status_code}
|
|
except Exception as e:
|
|
return {'error': str(e)} # 捕获异常并返回错误信息
|
|
|
|
# 发送请求到 /api/license/info 接口
|
|
def get_license_info():
|
|
target_url = 'http://127.0.0.1:5288/api/license/info'
|
|
try:
|
|
response = requests.get(target_url) # 使用 GET 请求
|
|
if response.status_code == 200:
|
|
return response.json() # 返回响应数据
|
|
else:
|
|
return {'error': 'Failed to fetch data from target API', 'status_code': response.status_code}
|
|
except Exception as e:
|
|
return {'error': str(e)} # 捕获异常并返回错误信息 |