Ratan1729/code-execution
1
1---2title: Code Execution Engine3emoji: ⚡4colorFrom: blue5colorTo: purple6sdk: docker7pinned: false8---9 10# Code Execution Engine11 12A high-performance code execution and judging engine supporting C, C++, and Python. Supports both Docker-based and process-based execution modes.13 14## Features15 16- **Multi-language support**: C (GCC 13.x), C++ (G++ 13.x with C++17), Python 3.1117- **Batch execution**: Compile once, run multiple test cases efficiently18- **Dual execution modes**:19 - **Docker mode**: Full isolation using sandbox containers (recommended for production)20 - **Process mode**: Direct subprocess execution (for Hugging Face Spaces)21- **RESTful API**: Simple endpoints for code execution and judging22 23## API Endpoints24 25| Endpoint | Method | Description |26| ------------------ | ------ | -------------------------------- |27| `/api/health` | GET | Health check |28| `/api/languages` | GET | List supported languages |29| `/api/execute` | POST | Execute code with single input |30| `/api/judge` | POST | Judge code against test cases |31| `/api/batch-judge` | POST | Batch judge multiple submissions |32 33## Deployment34 35### Hugging Face Spaces36 37Deploy using `Dockerfile.huggingface`:38 39```bash40# The Dockerfile.huggingface is configured for HF Spaces41# Set Space SDK to "Docker" and it will use this file42```43 44### Self-hosted (Docker)45 46```bash47docker-compose up -d48```49 50### Environment Variables51 52| Variable | Default | Description |53| ---------------------- | ------- | ----------------------------- |54| `PORT` | 3000 | Server port |55| `EXECUTION_MODE` | docker | `docker` or `process` |56| `MAX_CONCURRENT` | 2 | Max concurrent executions |57| `DEFAULT_TIME_LIMIT` | 5 | Time limit per test (seconds) |58| `DEFAULT_MEMORY_LIMIT` | 256 | Memory limit (MB) |59| `MAX_TIME_LIMIT` | 10 | Maximum allowed time limit |60| `MAX_MEMORY_LIMIT` | 512 | Maximum allowed memory |61 62## Quick Test63 64```bash65node test/quick-test.js http://localhost:300066```67 