An API which executes codes in a sandbox environment 🙀🤯.
Docker and docker compose should be installed in the system
Step 1 :
Clone the repo
Step 2 :
building the images
sudo docker-compose build
Step 3 :
running the images
sudo docker-compose up
Step 4 :
Testing if its working
If its running on localhost then ping the server using
-
On terminal:
curl http://localhost:9090/
We will get a response saying
Hello from Titan-Engine
with status code200
. -
On browser :
paste the url
http://localhost:9090/
and see the response. -
On Postman :
(recommended)
Sending a json post request to
http://localhost:9090/submit
{ "src": "\n\n#include<bits/stdc++.h>\n\nusing namespace std ;\n\nint main()\n{\n int a ;\n cin >> a ;\n\n cout << \"The first number is \" << a << endl ;\n \n int b ;\n cin >> b ;\n \n cout << \"The second number is \" << b << endl ;\n\n cout << \"Hello from cpp\" <<endl ;\n\n // while(1)\n // {\n // cout << 1 << endl ;\n // }\n return 0;\n}\n\n", "stdin": "48\n95", "lang": "cpp", "timeout": "5" }
we will get a response like
http://localhost:9090/results/Test646d62525e1b09171058
Run this response in postman or browser
src
contains the scripts in raw formate.
stdin
contains the inputs in raw formate.
lang
the programming language.
timeout
number of seconds the program will run.(Max 5 sec)
we will get a response like
http://localhost:9090/results/Test646d62525e1b09171058
Run this response in postman or browser
output
The output of the script
status
status of the output
stderr
error in code
submission_id
the unique submission id
error_message
the error message
time
time taken to run the script
"status": "Invalid Request"
If the field in post request is empty then it will show invalid request
"status":"Queued"
If the request is in waiting stage i.e. in queue.
"status":"Processing"
If the script is running
"status":"Runtime Error"
If the exec command fails for some reason in worker nodes
"status":"Failed"
Causes due to compilation error or runtime error.
"status":"Successful"
Everything is OK
https The port 8080 uses self signed ssl certificate.
http The port 9090 can be used for debugging.