Chuyển tới nội dung chính

Chạy tệp kịch bản

  • Mô tả giao diện

    POST /launch_script_file HTTP/1.1

    {"filename": "tên tệp kịch bản"}
  • Lưu ý
    filename là tùy chọn. Nếu bỏ qua, API dùng tệp kịch bản hiện được chọn.
    Trước tiên API tìm trong /var/mobile/Media/1ferver/lua/scripts/. Nếu không tìm thấy, đường dẫn được xử lý như đường dẫn tuyệt đối.

  • Phản hồi có thể có

    {"code":0,"message":"脚本运行开始"}
    {"code":1,"message":"操作失败"}
    {"code":2,"message":"脚本有语法错误","detail":"chi tiết lỗi cụ thể"}
    {"code":3,"message":"已有脚本正在运行中"}
    {"code":4,"message":"无法读取文件"}
    {"code":8,"message":"参数错误"}
    {"code":9,"message":"脚本已损坏"}
    {"code":10,"message":"软件需要更新方能支持使用这个脚本"}
  • Ví dụ Python 3.x để chạy kịch bản hiện được chọn, yêu cầu requests:

    # -*- coding: utf-8 -*-
    import requests

    resp = requests.post("http://192.168.31.72:46952/launch_script_file", timeout=30)

    if resp.status_code == 200:
    print(resp.json().get("message"))
    else:
    print(resp.status_code, resp.reason)
    print(resp.text)