Developer Tools provide two types of interfaces for external calls: command lines and HTTP services. Developers can indicate the tools to perform actions such as log in, preview, and upload through command lines or HTTP requests.
# HTTP
The http service is automatically started after the tool is started. The HTTP service port number is recorded in the user directory. You can check whether the tool is installed/started by checking whether there is a port file in the user directory and trying to connect.
Port number file location:
macOS: ~/Library/Application Support/Weixin Web Developer Tools/Default/.ide
Windows: ~/AppData/Local/Weixin Web Developer Tools/User Data/Default/.ide
# 1. Open a Tool or Specify a Project
Interface definition:
URL: /Open
HTTP method: GET
URL Parameter | Required | Description |
---|---|---|
projectpath | No | Open the project in the specified path. If the project is open, the project is automatically refreshed. If the project is not created, the project is automatically created and opened |
Example:
# Open tool
http://127.0.0.1:port number/open
# Open/Refresh project
http://127.0.0.1:port number/open?projectpath=project full path
Note:
- The project path must contain correctly formatted project.config.json with appid and projectname fields.
- The project path needs to be URL-encoded
# 2. Log In
Interface definition:
URL:/login
HTTP method: GET
URL Parameter | Required | Description |
---|---|---|
Format | No | Specifies the login QR code return format. Optional values include image, base64, terminal, and default image. Image format is png |
qroutput | No | Specify the file path and write the QR code data in the file. If specified, the QR code will be written to the file of the specified path. If not specified, the QR code will be returned as the request corresponding content. |
Example:
# Login, and return the QR code in image format
http://127.0.0.1:port number/login
# Login, and get the QR code in base64 format
http://127.0.0.1:port number/login?format=base64
# Login, get the QR code in base64 format and write it to /Users/username/logincode.txt
http://127.0.0.1:port number/login?format=base64&qroutput=%2FUsers%2Fusername%2Flogincode.txt
# 3. Preview
Interface definition:
URL:/preview
HTTP method: GET
URL Parameter | Required | Description |
---|---|---|
projectpath | Yes | Preview the project in the specified path. If the project is open, the project is automatically refreshed. If the project is not created, the project is automatically created and previewed |
Format | No | Specifies the login QR code return format. Optional values include image, base64, terminal, and default image. Image format is png |
qroutput | No | Specify the file path and write the QR code data in the file. If specified, the QR code will be written to the file of the specified path. If not specified, the QR code will be returned as the request corresponding content. |
Example:
# Preview the project with the path of /Users/username/demo and return the QR code in image format
http://127.0.0.1:port number/preview?projectpath=%2FUsers%2Fusername%2Fdemo
# Preview the project with the path of /Users/username/demo and return the QR code in base64 format
http://127.0.0.1:port number/preview?projectpath=%2FUsers%2Fusername%2Fdemo&format=base64
# Preview the project with the path of /Users/username/demo, return the QR code in base64 format, and write it to /Users/username/logincode.txt
http://127.0.0.1:port number/preview?projectpath=%2FUsers%2Fusername%2Fdemo&format=base64&qroutput=%2FUsers%2Fusername%2Flogincode.txt
# 4. Upload
Interface definition:
URL:/upload
HTTP method: GET
URL Parameter | Required | Description |
---|---|---|
projectpath | Yes | Upload the project in the specified path |
version | Yes | Version number |
desc | No | Uploaded version notes |
Example:
# Upload the project under /Users/username/demo, and specify the version number as 1.0.0
http://127.0.0.1:port number/upload?projectpath=%2FUsers%2Fusername%2Fdemo&version=v1.0.0
# Upload the project under /Users/username/demo, and specify the version number as 1.0.0 with notes
http://127.0.0.1:port number/upload?projectpath=%2FUsers%2Fusername%2Fdemo&version=v1.0.0&desc=test
# 5. Automated Test
Interface definition:
URL:/test
HTTP method: GET
URL Parameter | Required | Description |
---|---|---|
projectpath | Yes | Test the project in the specified path |
Example:
# Submit the project with the path of /Users/username/demo for test
http://127.0.0.1:port number/test?projectpath=%2FUsers%2Fusername%2Fdemo
# Request Response
Under normal circumstances, the HTTP corresponding state code is 200, and is 400 in error situations. It returns a JSON string with the following format:
{
"code": 40000,
"error": "reason"
}