{"id":24302832,"url":"https://github.com/narhen/code-exec-as-a-service","last_synced_at":"2025-03-06T14:26:53.560Z","repository":{"id":44865832,"uuid":"154732412","full_name":"narhen/code-exec-as-a-service","owner":"narhen","description":"RESTful web service for running code snippets","archived":false,"fork":false,"pushed_at":"2022-12-08T01:15:20.000Z","size":28,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T00:19:46.813Z","etag":null,"topics":["code-execution","code-snippet","docker","rest-api"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/narhen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-25T20:20:53.000Z","updated_at":"2024-12-07T22:06:14.000Z","dependencies_parsed_at":"2023-01-24T04:00:16.082Z","dependency_job_id":null,"html_url":"https://github.com/narhen/code-exec-as-a-service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narhen%2Fcode-exec-as-a-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narhen%2Fcode-exec-as-a-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narhen%2Fcode-exec-as-a-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narhen%2Fcode-exec-as-a-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/narhen","download_url":"https://codeload.github.com/narhen/code-exec-as-a-service/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242225879,"owners_count":20092667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-execution","code-snippet","docker","rest-api"],"created_at":"2025-01-17T00:19:32.252Z","updated_at":"2025-03-06T14:26:53.542Z","avatar_url":"https://github.com/narhen.png","language":"Python","readme":"# code-exec-as-a-service\nRESTful web service for running code snippets\n\n# Installing\n\n**Requirements**\n- [docker](https://docs.docker.com/install/)\n- [docker-compose](https://docs.docker.com/compose/install/)\n\n**Run with docker**\n1. `cd languages`\n2. `./build_images.sh`\n3. `cd ..`\n4. `docker-compose up -d`\n\n# How to use\n\nYou should first check which languages are available with the `GET /` endpoint.\nThe you submit the base64 encoded source code for your selected language along with input strings.\nThe program should read only one input from stdin at the time and exit when it has processed one input. Input is sent to the program similar to this:\n```bash\nfor input in inputs; then\n    printf $input | /path/to/program\ndone\n```\n\n## Adding support for new languages\nSee [languages/README.md](languages/README.md)\n\n## API endpoints\n\n### GET /\nReturns a list of available languages.\nExample response (200):\n```json\n[\"C\", \"python\", \"node\"]\n```\n\n### POST /exec/{language}\nPost source code and input to be sent to the process stdin.\nThe source code must be base64 encoded.\nExample request to `/exec/C` :\n```json\n{\n  \"source\": \"I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCmludCBtYWluKHZvaWQpCnsKICAgIGNoYXIgYnVmWzEwMjRdOwoKICAgIG1lbXNldChidWYsIDAsIHNpemVvZihidWYpKTsKICAgIGZnZXRzKGJ1Ziwgc2l6ZW9mKGJ1ZiksIHN0ZGluKTsKCXByaW50ZigiSGVsbG8gd29ybGQsICVzXG4iLCBidWYpOwoKCXJldHVybiAwOwp9Cg==\",\n  \"inputs\": [\"hi\\n\", \"man\\n\"]\n}\n```\nResponse (http 200):\n```json\n[\n  {\n    \"input\": \"hi\\n\",\n    \"output\": {\n      \"status\": \"OK\",\n      \"message\": \"Successfully executed code\",\n      \"output\": \"Hello world, hi\\n\\n\"\n    }\n  },\n  {\n    \"input\": \"man\\n\",\n    \"output\": {\n      \"status\": \"OK\",\n      \"message\": \"Successfully executed code\",\n      \"output\": \"Hello world, man\\n\\n\"\n    }\n  }\n]\n```\n\nIf the code fails to build a http 400 and a json-message with `\"status\"` = `\"BUILD_ERROR\"` will be returned:\n```json\n{\n  \"status\": \"BUILD_ERROR\",\n  \"message\": \"There was a build error\",\n  \"output\": \"code.c: In function 'main':\\ncode.c:12:10: error: expected ';' before '}' token\\n  return 0\\n          ^\\n          ;\\n }\\n ~         \\n\"\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnarhen%2Fcode-exec-as-a-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnarhen%2Fcode-exec-as-a-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnarhen%2Fcode-exec-as-a-service/lists"}