online-compiler-api
online-compiler-api copied to clipboard
Online compiler API using docker
Docker Compiler
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.

Language Supported
- Python 2
- Python 3
- Java 8
Requirements
- Python (2.x, 3.x)
- Django (1.8+)
- Django REST (3.x)
- Docker
Installation
-
Install docker.
-
Install python dependencies by running
pip install -r requirements.txt -
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> . -
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
-
Run the django development server by running the command
python manage.py runserver -
Make a POST api call to
http://localhost:8000/compile/codewith following parameters as form-data:- code: print "hello world"
- language: 'python'
- version: 2