py2cpp converts Python to C++17 with a Codeforces-style boilerplate, then compiles and runs both versions side-by-side on the same input.
AI-first: Qwen2.5-Coder (via Ollama) + a compile-and-repair loop.
Live UI:https://py2cpp.vercel.app/
- macOS with Homebrew
- Python 3.10+, Node 18+
- Ollama installed
- Model server
brew install ollama cloudflare/cloudflare/cloudflared
ollama serve
ollama pull qwen2.5-coder:7b- Backend
cd backend
python3 -m venv .venv &&source .venv/bin/activate
pip install -r requirements.txt
export OLLAMA_MODEL=qwen2.5-coder:7b
uvicorn main:app --host 0.0.0.0 --port 8000- Frontend
cd frontend
echo"VITE_API_URL=https://<your-tunnel>.trycloudflare.com"> .env
npm install && npm run devThe frontend is static. The backend (FastAPI + Ollama + g++) runs on your machine and must stay running.
- Public URL
cloudflared tunnel --url http://localhost:8000
# copy the https://<random>.trycloudflare.com URLNotes: Deployment can be only for frontend via netlify or vercel ; backend would be running locally constantly to work
POST /ai/convert → body { "py": "" } → { "cpp": "<full c++ file>" }
POST /run/python → { "code": "", "stdin": "" }
POST /run/cpp → { "code": "<c++>", "stdin": "" }
GET /healthz → { "ok": true }
macOS/Clang is handled by a fallback header set when <bits/stdc++.h> is unavailable.
Targeted at contest-style Python; highly dynamic features may require manual edits.
MIT © Birajit Saikia