Last active
June 17, 2019 01:49
-
-
Save hsjoihs/2038535a47b853587e1a261678595ed9 to your computer and use it in GitHub Desktop.
POST to wandbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST to wandbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() { int x = 0; std::cout << "hoge" << std::endl; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { readFileSync } from 'fs'; | |
const request = require('request'); | |
function emitRes(res) { | |
console.log("\n----compiler----------------"); | |
console.log(res.compiler_message); | |
console.log("\n----program-----------------"); | |
console.log(res.program_message); | |
console.log("\n----exit code---------------"); | |
console.log(res.status); | |
} | |
{ | |
let obj = { | |
"options": "warning,gnu++1y", | |
"compiler": "gcc-head", | |
"compiler-option-raw": "-Dx=hogefuga\n-O3" | |
}; | |
obj.code = readFileSync('/dev/stdin', 'utf8'); | |
const headers = { | |
'Content-type': 'application/json' | |
}; | |
const dataString = JSON.stringify(obj); | |
const options = { | |
url: 'https://wandbox.org/api/compile.json', | |
method: 'POST', | |
headers: headers, | |
body: dataString | |
}; | |
request(options, function(error, response, body) { | |
if (!error && response.statusCode == 200) { | |
emitRes(JSON.parse(body)); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo: | |
cat a.cpp | node -r esm main.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment