prasmussen / glot-run

API for running code inside docker containers
https://run.glot.io/
MIT License
147 stars 48 forks source link

Quotation mark (or escape characters?) processing issue #1

Closed bsapwindows closed 9 years ago

bsapwindows commented 9 years ago

The json file I sent (you can see the request here):

{"files": [{"name": "main.c", "content": '#include <stdio.h>

int main() {
    printf("Hello World!\n");
    return 0;
}'}]}

Got this in response:

{"stdout":"","stderr":"/tmp/812467442/main.c:4:12: warning: missing terminating '\"' character [-Winvalid-pp-token]\n    printf(\"Hello World!\n           ^\n/tmp/812467442/main.c:4:12: error: expected expression\n/tmp/812467442/main.c:5:1: warning: missing terminating '\"' character [-Winvalid-pp-token]\n\");\n^\n/tmp/812467442/main.c:7:2: error: expected '}'\n}\n ^\n/tmp/812467442/main.c:3:12: note: to match this '{'\nint main() {\n           ^\n2 warnings and 2 errors generated.\n","error":"exit status 1"}

If I delete the \n in printf("Hello World!\n");, it will compile successfully. I think it's something to do with string processing.


Thanks for creating glot BTW, it's a very cool project. I hope there will be an option to choose from different response formats, so I can get something like this without extra parsing:

$ glot.sh main.c
Hello World
$ glot.sh main.py
42

I've tried to set header to Content-type: text/plain, it returned nothing...

prasmussen commented 9 years ago

That's not valid json, I'm actually surprised that it was accepted by the api. You probably want to use a library to encode/decode the json data, but I'm not sure if bash is the most suitable language for this. Take a look at glot-cli, it might do what want.

prasmussen commented 9 years ago

On second thoughts don't use glot-cli yet, it has a serious design flaw. v1.2.0 should be fine.

bsapwindows commented 9 years ago

Thanks! Didn't know there's already a cli tool. I'll give it a try :smile: