update readme

This commit is contained in:
Brian Seymour 2021-01-22 02:58:45 -06:00
parent 014ddb3559
commit 563cf19068
1 changed files with 12 additions and 9 deletions

View File

@ -169,7 +169,7 @@ cd api
./start ./start
``` ```
For your own local installation, the API is available at</h3> For your own local installation, the API is available at:
``` ```
http://127.0.0.1:2000 http://127.0.0.1:2000
@ -177,9 +177,9 @@ http://127.0.0.1:2000
#### Versions Endpoint #### Versions Endpoint
`GET /versions` `GET /versions`
This endpoint takes no input and returns a JSON array of the currently installed languages. This endpoint will return the supported languages along with the current version and aliases. To execute
code for a particular language using the `/execute` endpoint, either the name or one of the aliases must
Truncated response sample: be provided.
```json ```json
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
@ -205,13 +205,16 @@ Content-Type: application/json
#### Execute Endpoint #### Execute Endpoint
`POST /execute` `POST /execute`
This endpoint takes the following JSON payload and expects at least the language and source. If This endpoint requests execution of some arbitrary code.
source is not provided, a blank file is passed as the source. If no `args` are desired, it can either - `language` (**required**) The language to use for execution, must be a string and supported by Piston (see list below).
be an empty array or left out entirely. - `source` (**required**) The source code to execute, must be a string.
- `stdin` (*optional*) The text to pass as stdin to the program. Must be a string or left out of the request.
- `args` (*optional*) The arguments to pass to the program. Must be an array or left out of the request.
```json ```json
{ {
"language": "js", "language": "js",
"source": "console.log(process.argv)", "source": "console.log(process.argv)",
"stdin": "",
"args": [ "args": [
"1", "1",
"2", "2",
@ -235,13 +238,13 @@ Content-Type: application/json
"stderr": "" "stderr": ""
} }
``` ```
If an invalid language is supplied, a typical response will look like the following: If a problem exists with the request, a `400` status code is returned and the reason in the `message` key.
```json ```json
HTTP/1.1 400 Bad Request HTTP/1.1 400 Bad Request
Content-Type: application/json Content-Type: application/json
{ {
"message": "Provided language is not supported by Piston" "message": "Supplied language is not supported by Piston"
} }
``` ```