This is the server for the V Playground.
Returns the playground index page.
Run the code and return the output.
If an error occurs, the error will be returned in the error
field.
Required form field:
code
— code to run
Additional form fields:
build_arguments
— build arguments when building binaryrun_arguments
— run arguments when running binaryrun_configuration
— run configuration type
curl -X POST localhost:5555/run -F 'code="println(100)"'
{
"output": "100",
"error": ""
}
Run the code as a test and return the output.
If an error occurs, the error will be returned in the error
field.
Required form field:
code
— code to test
Additional form fields:
build_arguments
— build arguments when building binaryrun_arguments
— run arguments when running binaryrun_configuration
— run configuration type
curl -X POST localhost:5555/run_test -F 'code="fn test_foo() { assert 100 == 100 }"'
{
"output": "---- Testing... <other output>",
"error": ""
}
Retrieve the C code generated from the passed V code.
If an error occurs, the error will be returned in the error
field.
Required form field:
code
— code to generate C code
Additional form fields:
build_arguments
— build arguments when building binary
curl -X POST localhost:5555/cgen -F 'code="println(100)"'
{
"cgenCode": "...",
"error": ""
}
Format the code and return the formatted code.
If an error occurs, the error will be returned in the error
field.
Required form field:
code
— code to format
curl -X POST localhost:5555/format -F 'code="println( 100 )"'
{
"output": "println(100)\n",
"error": ""
}
Share the code and return the hash.
If an error occurs, the error will be returned in the error
field.
Required form field:
code
— code to share
Additional form fields:
build_arguments
— build arguments when building binaryrun_arguments
— run arguments when running binaryrun_configuration
— run configuration type
curl -X POST localhost:5555/share -F 'code="println(100)"'
{
"hash": "21cf286fdb",
"error": ""
}
Return the code for the given hash.
If code for the hash does not exist, found
field will be false.
If an error occurs, the error will be returned in the error
field.
Returns JSON contains snippet
field which is the snippet for the hash.
Snippet structure is next:
{
"id": {
"type": "integer",
"description": "id of the snippet"
},
"code": {
"type": "string",
"description": "code of the snippet"
},
"hash": {
"type": "string",
"description": "hash of the snippet"
},
"build_arguments": {
"type": "array",
"description": "build arguments when building binary"
},
"run_arguments": {
"type": "array",
"description": "run arguments when running binary"
},
"run_configuration": {
"type": "integer",
"description": "run configuration type"
},
"additional": {
"type": "object",
"description": "additional data"
}
}
Required form field:
hash
— hash of the code
curl -X POST localhost:5555/query -F 'hash="21cf286fdb"'
{
"snippet": {
"id": 3,
"code": "println(100)",
"hash": "21cf286fdb",
"buildArguments": [],
"runArguments": [],
"runConfiguration": 0,
"additional": {}
},
"found": false,
"error": ""
}