index.py 1.22 KB
import requests

headers = {}

baser_url = "http://192.168.0.127:8081/"


def importJson(file, form_data):
    http_url = baser_url + "importJson/import"
    response = requests.post(http_url, headers=headers, files={"file": file}, data=form_data)
    # 将响应内容解析为 JSON 格式
    return {"status_code": response.status_code, "data": response.json()}


def getReptileTask():
    http_url = baser_url + "crawlerSetting/list"
    response = requests.get(http_url, headers=headers)
    # 将响应内容解析为 JSON 格式
    return {"status_code": response.status_code, "data": response.json()}


def importJsonPath(form_data):
    headers = {"Content-Type": "application/json"}
    http_url = baser_url + "importJson/importJsonPath"
    response = requests.post(http_url, headers=headers, data=form_data)
    # 将响应内容解析为 JSON 格式
    return {"status_code": response.status_code, "data": response.json()}


def runingPython(form_data):
    headers = {"Content-Type": "application/json"}
    http_url = baser_url + "python/startPy"
    response = requests.post(http_url, headers=headers, data=form_data)
    # 将响应内容解析为 JSON 格式
    return {"status_code": response.status_code, "data": response.json()}