A secure Python code execution environment that runs code in isolated Docker containers. This project provides two different frontend interfaces for the same backend mechanism.
- Secure Execution: Code runs in isolated Docker containers
- Real-time Output: See execution results and runtime immediately
- Modern UI: Beautiful, responsive interface
- Code Persistence: Your code is automatically saved
- Keyboard Shortcuts: Use Ctrl+Enter to run code quickly
- Error Handling: Clear error messages and status indicators
A modern, responsive web interface built with HTML, CSS, and JavaScript.
A Python-based web interface using Streamlit framework.
- Python 3.8+
- Docker installed and running
- Required Python packages (see requirements.txt)
- Clone the repository:
git clone <repository-url>
cd attempy-daa- Install dependencies:
pip install -r requirements.txt- Make sure Docker is running on your system.
- Start the FastAPI server:
python api_server.py- Open your browser and navigate to:
http://localhost:8000
- Write your Python code in the editor and click "Run Code" or press Ctrl+Enter.
- Start the Streamlit app:
streamlit run code_runner_app.py- The app will automatically open in your browser, or navigate to:
http://localhost:8501
adk webthis will start up the dev ui of the google adk package
The web frontend uses a REST API with the following endpoints:
GET /- Serve the main HTML pagePOST /api/run-code- Execute Python codeGET /api/health- Health check endpoint
Here are some examples you can try:
# Simple calculation
x = 10
y = 20
print(f"Sum: {x + y}")
print(f"Product: {x * y}")# List comprehensions
numbers = [1, 2, 3, 4, 5]
squares = [n**2 for n in numbers]
print(f"Squares: {squares}")
# Filter even numbers
evens = [n for n in numbers if n % 2 == 0]
print(f"Even numbers: {evens}")def factorial(n):
if n <= 1:
return 1
return n * factorial(n - 1)
print(f"Factorial of 5: {factorial(5)}")class Calculator:
def __init__(self):
self.history = []
def add(self, a, b):
result = a + b
self.history.append(f"{a} + {b} = {result}")
return result
calc = Calculator()
print(f"5 + 3 = {calc.add(5, 3)}")attempy-daa/
βββ api_server.py # FastAPI server for web frontend
βββ code_runner_app.py # Streamlit frontend
βββ container_runner.py # Core backend (Docker execution)
βββ requirements.txt # Python dependencies
βββ static/ # Web frontend files
β βββ index.html # Main HTML page
β βββ styles.css # CSS styles
β βββ script.js # JavaScript functionality
βββ README.md # This file
- Container Isolation: Each code execution runs in a separate Docker container
- Resource Limits: Containers are automatically removed after execution
- No Network Access: Containers run without network access by default
- Timeouts: Execution is limited to prevent infinite loops
You can add more example code by modifying the addExampleCode function in static/script.js.
The web frontend uses CSS custom properties and can be easily customized by modifying static/styles.css.
The ContainerRunner class in container_runner.py can be modified to:
- Use different Python versions
- Add more security restrictions
- Implement resource limits
- Add support for other programming languages
- Make sure Docker is running:
docker --version - Check if you have permission to run Docker commands
- On Windows/macOS, ensure Docker Desktop is running
- Web frontend uses port 8000 by default
- Streamlit uses port 8501 by default
- Change ports in the respective files if needed
- Check that your Python syntax is correct
- Ensure all required imports are included
- Remember that input() functions won't work (use fixed values instead)
- Fork the repository
- Create a feature branch
- Make your changes
- Test both frontends
- Submit a pull request
If you encounter any issues:
- Check the troubleshooting section
- Ensure all prerequisites are met
- Try running the code locally first
- Open an issue with detailed error information