Help with the wandbox online C++ compiler REST API please
Dear Boost, I've been trying to get Krzysztof's wandbox script turning into a generic set of reusable tools for the Best Practices Handbook (specifically some Python which will generate a standalone single header include from any library, and generic scripting which can reduce that single header include to the smallest possible representation), but I have a problem which I have failed to surmount, so any advice most gratefully received: ned@jenkins64:~/boost.afio$ ./send_to_wandbox.sh + json_wandbox send_to_wandbox.cpp afio_single_include.hpp + echo -e -n '{ "code" : ' + json_escape send_to_wandbox.cpp + cat send_to_wandbox.cpp + python -c 'import json,sys,codecs; sys.stdout.write(json.dumps(codecs.getreader("ISO-8859-1")(sys.stdin). read()))' + echo -e -n ', "codes": [ { "file": "afio_single_include.hpp", "code": ' + json_escape afio_single_include.hpp + cat afio_single_include.hpp + python -c 'import json,sys,codecs; sys.stdout.write(json.dumps(codecs.getreader("ISO-8859-1")(sys.stdin). read()))' + echo -e '}], "options": "warning,boost-1.58,c++14", "compiler": "clang-head", "save": true }' + curl -v -F json_file=@json_input.json http://melpon.org/wandbox/api/compile.json * Hostname was NOT found in DNS cache * Trying 49.212.130.73... * Connected to melpon.org (49.212.130.73) port 80 (#0)
POST /wandbox/api/compile.json HTTP/1.1 User-Agent: curl/7.35.0 Host: melpon.org Accept: */* Content-Length: 243073 Expect: 100-continue Content-Type: multipart/form-data; boundary=------------------------c58a2396982a31f8
< HTTP/1.1 100 Continue < HTTP/1.1 500 Internal Server Error * Server nginx/1.9.0 is not blacklisted < Server: nginx/1.9.0 < Date: Thu, 18 Jun 2015 23:56:48 GMT < Content-Type: text/html; charset=utf-8 < Transfer-Encoding: chunked < Connection: keep-alive < Status: 500 Internal Server Error < X-Powered-By: CppCMS/1.0.4 * HTTP error before end of send, stop sending < <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>500 — Internal Server Error</title> </head> <body> <h1>500 — Internal Server Error</h1> </body> </html> * Closing connection 0 + [[ '' != '' ]] + echo ned@jenkins64:~/boost.afio$ Whatever I do, I get Internal Server Error from wandbox. Yet copying and pasting the files manually into the web UI works as expected. I am stumped. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Niall Douglas
Dear Boost,
I've been trying to get Krzysztof's wandbox script turning into a generic set of reusable tools for the Best Practices Handbook (specifically some Python which will generate a standalone single header include from any library, and generic scripting which can reduce that single header include to the smallest possible representation), but I have a problem which I have failed to surmount, so any advice most gratefully received:
ned <at> jenkins64:~/boost.afio$ ./send_to_wandbox.sh [...]
Whatever I do, I get Internal Server Error from wandbox. Yet copying and pasting the files manually into the web UI works as expected.
I am stumped.
Perhaps you are overshooting the size limit of the JSON payload? I don't remember what that was, but I remember it happened with Hana so I decided to strip away the comments before I upload it to Wandbox. Anyway, I totally suck at bash scripting so here's the Python script I use to upload my stuff to Wandbox: https://github.com/ldionne/hana/blob/41c9d6e/cmake/wandbox.py It should be generic enough so that you can use it without many modifications. Regards, Louis
On 19 Jun 2015 at 0:59, Louis Dionne wrote:
Anyway, I totally suck at bash scripting so here's the Python script I use to upload my stuff to Wandbox:
https://github.com/ldionne/hana/blob/41c9d6e/cmake/wandbox.py
It should be generic enough so that you can use it without many modifications.
Your script works perfectly. Damn, I wasted many hours on mine. A *huge* thank you Louis. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Yea, Wandbox has some limits for the JSON payload, but I have never checked
it properly, because was working for my library our of the box. Guess it's
small enough.
On the other hand, wasn't working for Hana and, therefore, Louis asked for
the feature to sync whole dirs. The only issue with it is that tabs are
taking almost the whole screen, but it does work nicely.
Anyway, I was experimenting with Wandbox a bit more and noticed they do
allow cross http requests from js.
So, I tried to add edit/compile panel with examples and library taken
directly from github to the main website.
Used CodeMirror (https://codemirror.net/) for syntax highlighting as well
(code below).
This approach gives you the option to compile and modify all code examples
just by clicking a button, a bit like on http://cppreference.com, but with
your library.
They also allow to frame their website, so it may be added to the
documentation like here (
http://krzysztof-jusiak.github.io/di/cpp14/boost/libs/di/doc/html/di/try_it_...
).
<-------- index.html
<script src="cm/lib/codemirror.js"></script>
<script src="cm/mode/clike/clike.js"></script>
<script src="try_it_online.js"></script>
<textarea id="code" ></textarea>
<button onclick="compile_an_run()">Compile & Run</button>
<textarea id="result" ></textarea>
------------>
<--------------- try_it_online.js
var di = get_cpp_file("
https://raw.githubusercontent.com/krzysztof-jusiak/di/cpp14/include/boost/di...
");
function get_cpp_file(file) {
var cpp_file = new XMLHttpRequest();
cpp_file.open("GET", file, false);
cpp_file.send();
return cpp_file.responseText;
}
function compile_and_run() {
var http = new XMLHttpRequest();
http.open("POST", "http://melpon.org/wandbox/api/compile.json", false);
http.send(
JSON.stringify({
"code" : di
, "codes" : [{
"file" : "boost/di.hpp"
, "code" : di
}]
, "options":
"warning,cpp-pedantic-errors,optimize,boost-nothing,c++14"
, "compiler": "clang-head"
}));
result.value = http.response;
}
function get_examples() {
code.value = get_cpp_file("
https://raw.githubusercontent.com/krzysztof-jusiak/di/cpp14/example/try_it_o...
");
var cpp_code = CodeMirror.fromTextArea(code, {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-c++src"
});
cpp_code.setSize(900, 400);
var cpp_result = CodeMirror.fromTextArea(result, {
lineNumbers: false,
matchBrackets: true,
readOnly: true,
mode: "text/x-c++src"
});
cpp_result.setSize(900, 200);
}
------------->
On Fri, Jun 19, 2015 at 2:54 AM, Niall Douglas
On 19 Jun 2015 at 0:59, Louis Dionne wrote:
Anyway, I totally suck at bash scripting so here's the Python script I use to upload my stuff to Wandbox:
https://github.com/ldionne/hana/blob/41c9d6e/cmake/wandbox.py
It should be generic enough so that you can use it without many modifications.
Your script works perfectly. Damn, I wasted many hours on mine.
A *huge* thank you Louis.
Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
Krzysztof Jusiak
-
Louis Dionne
-
Niall Douglas