glotcode / glot

Code playground

Home Page:https://glot.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there an option to specify run command with glot-run API?

artemskikh opened this issue · comments

Sorry, I see that it's available on the website, but couldn't find any real API examples. Is it a thing (specifying custom run command)?

  • one more question: can the files array (in JSON request) contain a simple text file that is (not compiled, obviously) then used as a param in the run command?
    Basically, I'm looking for a way of running/testing the program with different input.

You can specify a custom run command with the command attribute.
And yes you can send in arbitrary text files. I made an example python snippet which reads a text file from stdin here: https://glot.io/snippets/ebj1rtktlt.

The api payload looks like this:

{
  "files": [
    {
      "name": "foo.py",
      "content": "import sys\n\nfor line in sys.stdin:\n    print(line.rstrip())"
    },
    {
      "name": "input.txt",
      "content": "1\n2\n3"
    }
  ],
  "command": "cat input.txt | python foo.py"
}

Thanks so much, exactly what I was looking for! Keep up the good work!