Skip to content

Commit 7cb1f38

Browse files
author
NaheedRayan
committed
added readme
1 parent c409b4e commit 7cb1f38

File tree

4 files changed

+62
-11
lines changed

4 files changed

+62
-11
lines changed

README.md

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,73 @@
22
An API which executes codes in a sandbox environment 🙀🤯.
33

44

5+
# Running the API
6+
<br>
57

6-
{
7-
"src": "\n\n#include<stdio.h>\n\nint main()\n{\n int a , b ;\n scanf(\"%d %d\", &a , &b) ;\n printf(\"The output is %d and %d \" , a , b );\n return 0;\n}\n\n\n",
8-
"stdin": "7\n9",
9-
"lang": "c",
10-
"timeout": "5"
11-
}
8+
### Prerequisites
9+
Docker and docker compose should be installed in the system
10+
11+
``Step 1 :``
12+
13+
Clone the repo
14+
15+
``Step 2 :`` building the images
16+
17+
sudo docker-compose build
18+
19+
``Step 3 :`` running the images
20+
21+
sudo docker-compose up
22+
23+
``Step 4 :`` Testing if its working
24+
25+
If its running on localhost then ping the server using
26+
27+
- On terminal:
28+
29+
curl http://localhost:9090/
30+
31+
We will get a response saying ```Hello from Titan-Engine``` with status code ``200``.
32+
33+
- On browser :
1234

35+
paste the url ``http://localhost:9090/`` and see the response.
1336

37+
- On Postman : ``(recommended)``
1438

39+
Sending a json post request to ``http://localhost:9090/submit``
1540

16-
{
17-
"src": "\n\n#include<bits/stdc++.h>\n \nusing namespace std ;\n\nint main()\n{\n int a , b ;\n\n cin >> a ;\n cout << \"The first number is \" << a << endl ;\n\n cin >> b ; \n cout << \"The second number is \" << b << endl ;\n\n while(1)\n {\n cout << \"Looping\" <<endl ;\n }\n\n return 0;\n\n}\n\n\n",
18-
"stdin": "45\n69",
41+
### It is a c++ script which takes 2 input and print's it.
42+
43+
```json
44+
{
45+
"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",
46+
"stdin": "48\n95",
1947
"lang": "cpp",
2048
"timeout": "5"
21-
}
49+
}
50+
```
51+
<br>
52+
53+
![](images/01.png)
54+
55+
we will get a response like
56+
57+
http://localhost:900/results/Test646d62525e1b09171058
58+
59+
60+
Run this response in postman or browser
61+
62+
![](images/02.png)
63+
64+
65+
<br>
66+
<br>
67+
<br>
68+
69+
70+
71+
# Understanding post request and responses
72+
2273

2374

images/01.png

40.9 KB
Loading

images/02.png

27.5 KB
Loading

server/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function random(size) {
4747
}
4848

4949
app.get('/' , (req,res)=>{
50-
res.status(200).send("Hello from browser");
50+
res.status(200).send("Hello from Titan-Engine");
5151
})
5252

5353
app.get('/redirect' , (req,res)=>{

0 commit comments

Comments
 (0)