go to your root dir and create your docker file with required dependencies
- Create an app in heroku
heroku create -a <your-app-name>
2.Push your container
heroku container:push web -a <your-app-name>
3.Finally release your app with
heroku container:release web -a <your-app-name>
Go to root directory online-compiler-api/ and run following commands
- Build docker image (this may take some time)
sudo docker build -t online-compiler-api .
- Run the container
sudo docker run -d -p 4888:3000 online-compiler-api
Starting API service on 3000 port (Make sure the port is not in use. If not change the port number in index.js).
npm start
Now visit http://localhost:3000/ this is your API endpoint( I have created a demo page to test the API)
This API support 5 languages C, C++, Java, Python , Javascript/nodejs
const id_lang = {
49: c,
54: cpp,
71:python,
63:node,
62:java
}
{
"language_id": "71",
"source_code":"a,b,c= input(),input(),input()\nprint(a)\nprint(b)\nprint(c)",
"stdin": "123\n321\nyogendra",
"expected_output":"123\n321\nyogendra",
"cpu_time_limit":3000
}
{
"stderr": null,
"memory": 1212416,
"compile_output": null,
"status": {
"description": "Accepted"
},
"expected_output": "123\n321\nyogendra",
"stdout": "123\n321\nyogendra"
}