Online compiler API using docker
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.
- Python 2
- Python 3
- Java 8
- Python (2.x, 3.x)
- Django (1.8+)
- Django REST (3.x)
- Docker
-
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.
-
Run the django development server by running the command
python manage.py runserver
-
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