Giter Club home page Giter Club logo

code-runner's Introduction

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"
    }

code-runner's People

Contributors

naiba avatar dependabot[bot] avatar

Stargazers

Daniel Bodnar avatar Swarnim Walavalkar avatar  avatar ObjectNotFound avatar E99p1ant avatar  avatar

Watchers

 avatar  avatar

code-runner's Issues

Missing config.json file

On first run the api will panic and return this error:

panic: open data/config.json: no such file or directory

goroutine 1 [running]:
main.init.0()
        /home/snow/code-runner/cmd/api/main.go:42 +0x1e8
exit status 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.