You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.1 KiB

代码质量检查API文档

API端点

  • URL/check

  • 方法POST

  • 请求格式multipart/form-data

  • 请求参数

    • file (文件)要检查的Python代码文件必需
    • tools (字符串):逗号分隔的工具列表,例如 "bandit,flake8,pylint"(必需,至少一个)。
  • 响应格式JSON

    • 成功200 OK
      {
        "results": [
          {
            "tool": "bandit",
            "stdout": "...检查输出...",
            "stderr": "...错误信息(如果有)..."
          },
          // 其他工具的结果
        ]
      }
      
    • 错误400 Bad Request
      {
        "error": "No file uploaded" // 或其他错误消息
      }
      
  • 示例请求 (使用curl)

    curl -X POST http://localhost:3000/check \
      -F "file=@D:\软件工程\代码质量检查\src\test_sample.py" \
      -F "tools=bandit,flake8,pylint"
    
  • 注意

    • 支持的工具bandit、flake8、pylint大小写不敏感
    • 文件会临时保存并在检查后删除。
    • 如果工具运行失败stderr会包含错误详情。