A simple web service built with FastAPI to execute code files in different programming languages within a Docker container. This project allows you to upload a code file along with arguments, specify the programming language, and execute the code. Currently, it supports Python, with plans to expand to more languages in the future.
- Execute code files in Python using FastAPI.
- Upload files along with arguments to run the code.
- Simple API endpoint for running code.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Docker
- Python 3
- Clone the repository:
git clone https://github.com/mosishon/fastapi-code-runner.git
- Navigate to the project directory:
cd fastapi-code-runner
- Build the Docker image:
docker build -t fastapi-code-runner .
- Run the FastAPI Code Runner Docker container named "runner" on port {PORT}, with automatic restart, CPU limit of 0.5, and memory limit of 512 MB, allowing users to customize CPU and RAM limits as needed.:
docker run --name runner -p {PORT}:8000 --restart=always --cpus=0.5 --memory="512m" -d fastapi-code-runner
The FastAPI Code Runner currently supports the following programming languages:
- python: A versatile and easy-to-learn programming language widely used for various applications.
- javascript: A popular scripting language often used for web development.
- php: A server-side scripting language commonly used for web development.
- ruby: A dynamic, object-oriented programming language known for its simplicity and productivity.
Stay tuned for updates as we continue to expand language support in future releases!
Executes the uploaded code file.
file
: The code file to be executed (multipart form-data).args
: Arguments to be passed to the code file (form field).language
: Programming language of the code file (form field).
file-size
: Size of the uploaded file.result
: Result of executing the code.language
: Programming language used.file-path
: File path of the uploaded code file.
Contributions are welcome! Please feel free to submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.