Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/naiba-archived/code-runner
:construction_worker: Docker-based remote code runner with simple API.
https://github.com/naiba-archived/code-runner
Last synced: 3 months ago
JSON representation
:construction_worker: Docker-based remote code runner with simple API.
- Host: GitHub
- URL: https://github.com/naiba-archived/code-runner
- Owner: naiba-archived
- License: mit
- Created: 2020-09-22T15:59:07.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-23T02:12:43.000Z (9 months ago)
- Last Synced: 2024-07-24T01:59:49.282Z (4 months ago)
- Language: Go
- Homepage:
- Size: 83 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Remote Code Runner
:construction_worker: Docker-based remote code runner with simple API.
## Supported Languages
Go/GCC
## API
- List supported runners: `GET /api/list`
```json
{
"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:
```sh
# 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:
```json
{
"code":"package main\nfunc main() {print(\"hello world!\")}",
"container":"golang-latest"
}
```**(Don't forget the HTTP basic authentication header)**
Response Body:
```json
{
"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"
}
```