tarungarg546 / HackerEarth-node

nodeJS library for using HackerEarth API
29 stars 8 forks source link

Help me #8

Closed wdvvgy closed 5 years ago

wdvvgy commented 7 years ago

Well, it does not work right now. There is no response from the Restful API.

I found this instead of a normal response. body: '\r\n504 Gateway Time-out\r\n\r\n

504 Gateway Time-out

\r\n</body

\r\n\r\n' } }

I think the server is abnormal. Could you confirm it?

` router.post('/run', (req, res) => { const { code, mode } = req.body.obj; if(typeof code !== 'string' || typeof mode !== 'string') return res.json({message: 'Bad Request'});

let config = { };
config.time_limit = 1;
config.memory_limit=323244;  //your memory limit in integer
config.source = code;  //your source code for which you want to use hackerEarth api
config.input = "";  //input against which you have to test your source code
if(mode === 'c_cpp') config.language = 'CPP11';
else if(mode === 'java') config.language = 'JAVA';
else if(mode === 'javascript') config.language = 'JAVASCRIPT_NODE';
else if(mode === 'python') config.language = 'Py';
else return res.json({message: 'Bad Request'});
console.log(code);
console.log(mode);
// compile & run
runModule.compile(config)
.then(result => {
    runModule.run(config).then(result => {
        return res.json({message: 'run success',result});
    }).catch(err => {
        console.log(err);
        return res.json(err);
    });
}).catch(err => {
    console.log(err);
    return res.json(err);
});

}); `

tarungarg546 commented 7 years ago

504 generally means that server took too long to revert back with a response and forward-reverse proxy terminated that connection midway i.e. there is some mistake from HackerEarth end.

Will check and revert here!

wdvvgy commented 7 years ago

Thank you.... Your node api is very helpful for me ^^