You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<summary><h3>POST Route: /simple-execute (click to expand)</h3></summary>
20
20
21
21
This route is a drop in replacement for [CodeExecutionAPI](https://github.com/thealcodingclub/CodeExecutionAPI), just take the code where you called the old API and replace `https://codeapi.anga.codes/execute` with `${url}/simple-execute` and watch as ur response times get faster!.
22
22
@@ -27,7 +27,6 @@ This route takes 4 fields:
27
27
<summary>Click to see supported languages</summary>
28
28
29
29
- python
30
-
- rust
31
30
- cpp
32
31
- c
33
32
- java
@@ -38,9 +37,10 @@ This route takes 4 fields:
38
37
3.`timeout` (optional field): The maximum number of seconds for which the code should run. If the code takes more time to execute than what it was allocated, it will be terminated.
39
38
- default (value assumed if you dont specify): **5 seconds**
40
39
- max (you can't allocate more seconds than this): **60 seconds**
41
-
4.`max_memory`: The maximum memory in KB (kilobytes) that the code can use. If the code uses more memory than this, it will be terminated.
40
+
4.`max_memory` (optional field): The maximum memory in KB (kilobytes) that the code can use. If the code uses more memory than this, it will be terminated.
42
41
- default (value assumed if you dont specify): **32768KB** (or 32MB)
43
42
- max (you can't allocate more RAM than this): **131072KB** (or 128MB)
43
+
5.`inputs` (optional field): This is an array of strings where every element is 1 line, its completely optional and you should use it if your code reads input from STDIN (like with python input() or scanf() in C), read example 4 to see usage
44
44
45
45
*Note: the above mentioned default and max values can be modified by editing the environment variables mentioned at the bottom of this README*
**Note**: the route `/simple-execute` also calls `/execute` under the hood, its just that the formatting for the input and output are slightly more easy to read and understand.
206
206
<details>
207
207
<summary><h3>POST Route: /execute</h3></summary>
208
-
Will type this out soon
208
+
209
+
This route takes 4 fields:
210
+
211
+
1.`langauge`: The language of the code snippet.
212
+
<details>
213
+
<summary>Click to see supported languages</summary>
214
+
215
+
- python
216
+
- cpp
217
+
- c
218
+
- java
219
+
220
+
</details>
221
+
222
+
2.`code`: The code snippet to be executed.
223
+
3.`timeout` (optional field): The maximum number of **nanoseconds** for which the code should run. If the code takes more time to execute than what it was allocated, it will be terminated.
224
+
- default (value assumed if you dont specify): **5 seconds**
225
+
- max (you can't allocate more seconds than this): **60 seconds**
226
+
4.`max_memory` (optional field): The maximum memory in KB (kilobytes) that the code can use. If the code uses more memory than this, it will be terminated.
227
+
- default (value assumed if you dont specify): **32768KB** (or 32MB)
228
+
- max (you can't allocate more RAM than this): **131072KB** (or 128MB)
229
+
5.`inputs` (optional field): This is a single string that is fed to the code via STDIN at runtime, if you want multiple lines in STDIN then separate them with `\n`, its completely optional and you should use it if your code reads input from STDIN (like with python input() or scanf() in C), read example 4 to see usage
230
+
231
+
*Note: the above mentioned default and max values can be modified by editing the environment variables mentioned at the bottom of this README*
232
+
233
+
---
234
+
235
+
#### Request body format (Example 1):
236
+
237
+
```json
238
+
{
239
+
"language": "python",
240
+
"code": "print('Hello World')"
241
+
}
242
+
```
243
+
<details>
244
+
<summary>Click to copy curl command</summary>
245
+
246
+
```bash
247
+
curl --location '${url}/execute' \
248
+
--header 'Content-Type: application/json' \
249
+
--data '{
250
+
"language": "python",
251
+
"code": "print('\''Hello World'\'')"
252
+
}'
253
+
```
254
+
255
+
</details>
256
+
257
+
#### Response body format (Example 1):
258
+
259
+
```json
260
+
{
261
+
"output": "Hello World\n", // output from STDOUT
262
+
"error": "", // output from STDERR
263
+
"cpu_time": 10283909, // run time in nanoseconds (10ms or 0.01 seconds)
-`ENABLE_DEBUG`: if true, the server will expose debug routes (like `/check-ram`) for monitoring and debugging purposes
238
411
- same format as `ENABLE_QUEUE`
239
412
- by default this is `false`
240
-
- the public API has this set to `true`
413
+
- the public API has this set to `true`
414
+
-`GIN_MODE`: wether to run the gonic-gin server in release mode or debug mode, for this API there wont be much of a performance difference regardless of which one you pick, it is reccomended that you read the docs for [gonic gin](https://gin-gonic.com/en/docs/deployment/#configuration-options) for more information
415
+
- this can be set to `release` or `debug`
416
+
- by default it is set to `debug`
417
+
- the public API has this set to `release`
418
+
-`PORT`: Which network port to run the server on
419
+
- this can be set to any unsigned integer value between `0` and `65535`
420
+
- by default this is `8080`
421
+
- public API has this set to `8080`
422
+
423
+
**Note:***if you are self-hosting this api, remember to run it with superuser permissions, or a user which has permissions to alter controlgroups and namespaces, normally you can achieve this just by using "sudo" before running the code*
0 commit comments