CoolFace
Apppublic

Ratan1729/code-execution

sourceHugging Faceupdated 8mo agoView on Hugging Face
1likes
App README

Code Execution Engine

A high-performance code execution and judging engine supporting C, C++, and Python. Supports both Docker-based and process-based execution modes.

Features

  • Multi-language support: C (GCC 13.x), C++ (G++ 13.x with C++17), Python 3.11
  • Batch execution: Compile once, run multiple test cases efficiently
  • Dual execution modes:
  • Docker mode: Full isolation using sandbox containers (recommended for production)
  • Process mode: Direct subprocess execution (for Hugging Face Spaces)
  • RESTful API: Simple endpoints for code execution and judging

API Endpoints

EndpointMethodDescription
/api/healthGETHealth check
/api/languagesGETList supported languages
/api/executePOSTExecute code with single input
/api/judgePOSTJudge code against test cases
/api/batch-judgePOSTBatch judge multiple submissions

Deployment

Hugging Face Spaces

Deploy using Dockerfile.huggingface:

bash
# The Dockerfile.huggingface is configured for HF Spaces
# Set Space SDK to "Docker" and it will use this file

Self-hosted (Docker)

bash
docker-compose up -d

Environment Variables

VariableDefaultDescription
PORT3000Server port
EXECUTION_MODEdockerdocker or process
MAX_CONCURRENT2Max concurrent executions
DEFAULT_TIME_LIMIT5Time limit per test (seconds)
DEFAULT_MEMORY_LIMIT256Memory limit (MB)
MAX_TIME_LIMIT10Maximum allowed time limit
MAX_MEMORY_LIMIT512Maximum allowed memory

Quick Test

bash
node test/quick-test.js http://localhost:3000