/online-compiler-api

Online compiler API using docker

Primary LanguagePythonMIT LicenseMIT

Docker Compiler

Open Source Love

Online compiler API using docker

Overview

This uses docker to compile untrusted code from the client and DRF is used to provide the high level api.
Just a simple POST call with form data is enough to compile the code and get the output.

Alt Text

Language Supported

  1. Python 2
  2. Python 3
  3. Java 8

Requirements

  • Python (2.x, 3.x)
  • Django (1.8+)
  • Django REST (3.x)
  • Docker

Installation

  1. Install docker.

  2. Install python dependencies by running
    pip install -r requirements.txt

  3. Go to the root of the code directory where the Dockerfile is located and build the docker image by running
    docker build -t <image_name> .

  4. Open config.py and set the base parameters:

    • DOCKER_IMAGE : The name of the docker image created
    • LOCAL_DIR : The path of the local directory needed to save the code.

Execution

  1. Run the django development server by running the command
    python manage.py runserver

  2. Make a POST api call to http://localhost:8000/compile/code with following parameters as form-data:

    • code: print "hello world"
    • language: 'python'
    • version: 2