prasmussen / glot-run

API for running code inside docker containers

Home Page:https://run.glot.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quotation mark (or escape characters?) processing issue

bsapwindows opened this issue · comments

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...

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.

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

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