Coder Social home page Coder Social logo

jaagrav / codex-api Goto Github PK

View Code? Open in Web Editor NEW
187.0 187.0 64.0 35 KB

The new version of CodeX API with it's backend, a lot of you wanted me to make the backend opensource, now it's ready to receive contributions from you. Thanks for being patient, more languages coming soon, happy hacking!

Home Page: https://codex.jaagrav.in/

License: MIT License

JavaScript 91.49% Dockerfile 8.51%
hacktoberfest hacktoberfest2022

codex-api's People

Contributors

akira-cn avatar codersk avatar jaagrav avatar yasserdbeis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

codex-api's Issues

Api stopped working

its giving a 500 server response :(. Please get it up again, its really really useful, thanks

[Enhancement] Add compilation/running of multiple files

Future feature to be implemented: running code with multiple files.

This seems fairly straight forward with compiled languages. For example, for c/cpp we can send the code as an array of strings, have the file for each code string created, and the g++ command should take care of the rest in creating the executable. Some minor accomodations may need to be made to differentiate b/w header and non-header files, but that is not a big deal.

For interpreted languages, like python, I am not sure its as straight forward with the current mechanism. This is because if a python file imports from a file called "x", the imported filename will be modified to a UUID with the current set-up and thus the import statement will be broken. However, I might be misunderstanding and welcome criticism/solutions.

How do I get stdin input with javascript?

const input = require('fs').readFileSync('/dev/stdin').toString().split(' ');
console.log(Number(input[0]) + Number(input[1]));

With this code, I get error
"node:internal/fs/utils:344\n throw err;\n ^\n\nError: ENXIO: no such device or address, open '/dev/stdin'\n at Object.openSync (node:fs:585:3)\n at Object.readFileSync (node:fs:453:35)\n at Object. (/app/codes/10609b19-df6a-4e33-8cc6-f31183eb3f29.js:1:29)\n at Module._compile (node:internal/modules/cjs/loader:1101:14)\n at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)\n at Module.load (node:internal/modules/cjs/loader:981:32)\n at Function.Module._load (node:internal/modules/cjs/loader:822:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)\n at node:internal/main/run_main_module:17:47 {\n errno: -6,\n syscall: 'open',\n code: 'ENXIO',\n path: '/dev/stdin'\n}\n"

How can i access to stdin in javascript?

Installation takes a long time

Installation takes a long time. Docker Build is stuck at stage 7/15.
GET 371 ubuntu npm.
The package has been downloaded a million times already. I've been waiting for more than 10 hours. I tried again, but the result did not change. Here is a screenshot
System: Centos 7, docker is latest version.
image

How to use this API

Hi,

You have done great work. Can I know, How to use CodeX Api.

Thank You!

discontinued?

is this discontinued cuz its says that the service has been suspended

Java code not working

I cloned this project, run rpm install. Everything seems to working fine. I tested c, cpp, js codes, all work fine but java code is not working.

case 'java':
            return {
                executeCodeCommand: 'java',
                executionArgs: [
                    join(process.cwd(), `codes/${jobID}.java`)
                ],
                compilerInfoCommand: 'java --version'
            };

Remote code execution

Hey I was actually analyzing the Codex API (which by the way is actually superb). While doing so one thing crossed my mind can I run this:

const testFolder = './';
const fs = require('fs');

fs.readdir(testFolder, (err, files) => {
  files.forEach(file => {
    console.log(file);
  });
});

I am not exactly about testFolder path, but I did put in something. When I executed the script it did give me the list of the contents (files & folders) in that directory. Now do the following:

// Instead of console.log(file); do
fs.unlinkSync(file)

I have a temporary solution for this too, using node >=20 with Experimental Permission Model. It also helps us decide where we can run exec. But this solution is not great, May be we have to first analyze the code making sure it is not accessing something it should not. Then go ahead and use some proper Linux resource permission etc.

It I get around will link a pull request.

Thanks
Anweshan ([email protected])
Office: [email protected]

Api Stopped working

Api has stopped working we're not able to use it anymore
Isuues:
{
"timeStamp": 1707629578253,
"status": 500,
"errno": -2,
"syscall": "open",
"code": "ENOENT",
"path": "/app/codes/c1e8d4c9-d328-438a-a450-dfbde74f4681.java"
}
it shows errorcode:500
please fix it

C language seems to be using a cpp compiler?

When I try to compile my C code using the CodeX C compiler, i get a lot of errors complaining about casting a void* to something else, which is fine in C however forbidden in CPP (source: https://stackoverflow.com/a/22744183/11804669)

Which is really weird because that would mean the C language for CodeX is actually compiled as if it was C++

So as a test I tried copy pasting a C++ Hello World script into it (which should not AT ALL) compile if it was really C

and that worked

[Enhancement] Repetitive Code to Run/Execute Each Language

Creating this as an issue to be tackled in a future PR.

Just noticed that the code to run/execute each language is basically the same, minus the spawn command. Thought the code could be refactored to avoid such redudancy.

I will likely pick this issue up if someone does not already in the upcoming day(s).

API has crashed

Getting the following response

response: {
status: 503,
statusText: 'Service Unavailable',
headers: {
connection: 'close',
server: 'Cowboy',
date: 'Sun, 30 Oct 2022 07:40:57 GMT',
'content-length': '506',
'content-type': 'text/html; charset=utf-8',
'cache-control': 'no-cache, no-store'
},

Implementation in Java

private JSONObject getCompileResult(String code, String input, String language) throws UnirestException { Unirest.setTimeouts(0, 0); HttpResponse<String> response = Unirest.post("https://codex-api.herokuapp.com") .header("Content-Type", "application/x-www-form-urlencoded") .field("code", code) .field("language", language) .field("input", input==null ? "" : input) .asString(); return new JSONObject(response.getBody()); }

Issue with API

API having issue right now

POST is not working

image

{
    "timeStamp": 1688111559630,
    "status": 500,
    "errno": -2,
    "syscall": "open",
    "code": "ENOENT",
    "path": "/app/codes/ae816f83-a965-42bf-8378-732ad5ddda98.java"
}


get is working well

i remember the last time.
same issue started before actually shutting down all functions.

image

API is crashed

I written a program in C++ for infinite memory usage which is as follows

#include<iostream>
using namespace std;

int main() {
    while(true) {
        int *n = new int[10000];
    }
}

I think the API has been crashed after executing above code as it is showing 'Network Error' now (earlier it was working fine). please try to resolve this issue and place a limit on memory usage and execution time.

Can’t use api

I’m getting an 405 error every time. “Method not allowed” and I’m using POST method

Internal server error

While i was testing API call through postman extension in vs code i got this error ...
image

Deploy in another platform

As from 28th Nov 2022 Heroku going to charge money for free dynos ,so I am saying you to host it another platform to get free api hosting service. Thank you!!

Working with multiple input

Is there a way to work with multiple input? For example the code is java, and asking twice for getting input from users.

Python code compilation error

Encountering error during compilation of code with more than one input. Here is the code:
a = input()
b = input()
print(a, b)

And here is the compilation message:

Traceback (most recent call last):
File "/app/codes/63db007e-7ed3-473e-abe9-d5a0e2c95fa8.py", line 2, in
b = input()
EOFError: EOF when reading a line

[Security Vulnerability] Allowing malicious code injection.

I have identified a security vulnerability in the CodeX-API repository. The vulnerability allows an attacker to inject malicious code into the server, which can potentially harm the server and allow unauthorized access to sensitive information. Specifically, an attacker is able to delete files on the server using javascript or other programming language.

This security vulnerability poses a significant threat to the project's integrity and the security of the data stored in the server.

impossibility to use pointers or anything that needs the adress of a variable in c

its impossible to do so cause if we use the & character it just doesnt work and it ends the code at that points ( probably because after the & after the code is expecting the language ), so, its basicly impossible to do anything in C, am i just being dumb or is it really a bug?

(( without the scanf(\"%i\", &ia); part and the input=10 part the code works but i really need the input part for what im doing ))

"code=#include<stdio.h>\nint main(){\nprintf("meow");\nint ia = 0;\nscanf("%i", &ia);\n printf("%i", ia);\n\n}\n&language=c&input=10"

image

Delayed asynchronous code features

Is there a way to work with asynchronous code that have delay? For example, setTimeout() in javascript.

If i made a code inside the timeout and make the delay to be 2 seconds, all of the code just executed. Here is example code

console.log("before timeout");
setTimeout(() => {
    console.log("inside timeout");
}, 2000);

Issue with API

api is not working properly getting response like -->

code:"ENOENT"
errno:2
path:"/app/codes/4cfb0f33-3ec6-464e-8eed-be734ed1ab41.py"
status:500
syscall:"open"
timeStamp:1685425605602

Heroku Issue

As Heroku has closed its free tiers the API is down. Please host it on sites like railway or porter so that the API can be up again. Thank you for the amazing API.

API has crashed

When I try to compile code, I get the Heroku Application error.
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.