A web-based Python code editor that allows users to write and execute Python code directly in their browser. Built with Flask backend and CodeMirror frontend, featuring syntax highlighting, dark theme, and real-time code execution.
Live Demo:https://viks-online-code-editor.vercel.app/
- 🐍 Python Code Execution - Write and run Python code directly in the browser
- 🎨 Syntax Highlighting - CodeMirror editor with Dracula theme for a pleasant coding experience
- 🌙 Dark Theme - Modern dark UI with neon accents
- ⚡ Real-time Execution - Execute code and see output instantly
- 🧹 Clear Functionality - Clear editor and output with a single click
- 📱 Responsive Design - Works on desktop and mobile devices
- Flask - Python web framework
- subprocess - For executing Python code securely
- CodeMirror - Code editor with syntax highlighting
- JavaScript - For handling user interactions and API calls
- HTML/CSS - Modern, responsive UI
- Vercel - Serverless deployment platform
- Python 3.7 or higher
- pip (Python package manager)
- Clone the repository:
git clone <repository-url>cd OnlineCodeEditor- Install dependencies:
pip install -r requirements.txt- Run the application:
python app.py- Open your browser and navigate to:
http://localhost:5000
- Write Code: Type your Python code in the editor
- Run Code: Click the "Run Code" button to execute your code
- View Output: See the output or error messages in the output section
- Clear: Use the "Clear" button to reset the editor and output
OnlineCodeEditor/
├── app.py # Flask application and API routes
├── requirements.txt # Python dependencies
├── vercel.json # Vercel deployment configuration
├── templates/
│ └── index.html # Main HTML template
└── static/
├── css/
│ └── style.css # Styling for the application
├── script.js # JavaScript for editor functionality
└── style.css # Additional styles
Execute Python code and return the output.
Request Body:
{
"code": "print('Hello, World!')"
}Response:
{
"output": "Hello, World!\n"
}This project is configured for deployment on Vercel. The vercel.json file contains the deployment configuration.
To deploy:
- Install Vercel CLI:
npm i -g vercel - Run
vercelin the project directory - Follow the prompts to deploy
The application handles various error scenarios:
- Python not found on the system
- Code execution errors
- Syntax errors in user code
- Network errors
- Code execution is done server-side using subprocess
- No file system access for security reasons
- Limited to Python code execution
- No support for multi-file projects
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is open source and available under the MIT License.
After 2 weeks of working on this project, I can say:
