Discover Packages
github.com/naiba/code-runner
module
Version:
v0.0.0-...-362f3e3
Opens a new window with list of versions in this module.
Published: Feb 23, 2024
License: MIT
Opens a new window with license information.
README
README
¶
Remote Code Runner
👷 Docker-based remote code runner with simple API.
Supported Languages
Go/GCC
API
List supported runners: GET /api/list
{
"golang-latest":{
"image":"golang:alpine",
"target":"/runner/main.go",
"template":"package main\\nfunc main(){\\nprint(\"hello world!\")}",
"cmd":[
"sh",
"-c",
"set -x \u0026\u0026 cd /runner \u0026\u0026 go build -o main main.go \u0026\u0026 ./main"
],
"limit":{
"cpu":10,
"mem":50
}
}
}
Run the code snippet: POST /api/task
cURL:
# dXNlcm5hbWU6cGFzc3dvcmQ=: base64(username:password)
curl -X POST \
'http://localhost:3000/api/run' \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{
"code":"int main(){printf(\"Hello world!\");}",
"container":"gcc-latest"'
Request Body:
{
"code":"package main\nfunc main() {print(\"hello world!\")}",
"container":"golang-latest"
}
(Don't forget the HTTP basic authentication header)
Response Body:
{
"code": 0,
"out": "\u0002\u0000\u0000\u0000\u0000\u0000\u0000\r+ cd /runner\n\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u001b+ go build -o main main.go\n\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0019# command-line-arguments\n\u0002\u0000\u0000\u0000\u0000\u0000\u0000?./main.go:2:35: syntax error: unexpected x at end of statement\n"
}
Expand ▾
Collapse ▴
Directories
¶
cmd
internal
Click to show internal directories.
Click to hide internal directories.