This task can be performed using Whipcode
A low cost REST API for running untrusted code
Best product for this task

Whipcode
dev-tools
Whipcode provides a secure, isolated environment for running untrusted code, seamlessly integrating into your application. Let us handle the heavy lifting, so you can focus on building, scaling, and innovating your solution. - Support for 25+ languages - Custom compiler options and timeouts - Pay-per-use pricing model - Open source backend

What to expect from an ideal product
- Uses secure containers to run different programming languages side by side
- Connects various languages through a simple API without complex setup
- Handles cross-language communication automatically in the background
- Lets you mix and match 25+ programming languages in one project
- Takes care of compiler settings and resource management across languages