webbben / code-exec-microservice

A simple microservice API for executing code snippets and returning their output
https://code-exec-microservice.fly.dev/
0 stars 0 forks source link
code-execution golang

Code Execution Microservice

This is a code execution microservice that will execute code snippets in specific programming languages. It's an HTTP server that exposes a POST API endpoint which allows you to send code, and it returns the output and whether an error occurred during its execution.

As of now, these are the supported programming languages:

How it works

The actual code execution is relatively simple:

This does mean that a code snippet needs to print something out to stdout (i.e. print() in Python) for our program to get any output data. So, consuming applications should consider that and make sure to add code that prints to stdout whatever data they want from the execution.

How to use

Make a POST request to the following URL: https://code-exec-microservice.fly.dev/ In the request body, include JSON data in the following format:

{
  "code": "print(\"Hello world!\")",
  "lang": "python"
}

Performance

(todo)

Future

Here are things I'll consider adding in the future: