A real-time, interactive web-based terminal interface powered by Python's pexpect library, Flask, WebSockets, and xterm.js.
This application creates a fully interactive web terminal that communicates with a bash/sh shell running on the server. The terminal provides a seamless experience that mimics a native terminal application, with real-time streaming of output via WebSockets and direct keyboard input.
- Full-screen terminal interface using xterm.js for proper terminal emulation
- Correct handling of ANSI escape sequences and control characters
- Shared terminal state across multiple browser windows/tabs
- Persistent terminal buffer that preserves history between connections
- Real-time streaming of terminal output via WebSockets to all connected clients
- Complete keyboard input support (all keys and key combinations)
- Reset terminal session and clear screen options
- Responsive design that automatically resizes the terminal
- Continuous output streaming without timeouts
- Python 3.x
- Flask
- Flask-SocketIO
- pexpect
- eventlet
- Clone this repository
- Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Start the application:
or use the convenience script:
python app.py
./run.sh
- Open your web browser and navigate to
http://localhost:5050
- Click anywhere in the black terminal area to focus and start typing
- Use the terminal as you would a regular terminal - all keyboard input is sent directly to the shell
This application executes shell commands on the server. In a production environment, additional security measures should be implemented:
- User authentication
- Command validation and sanitization
- Access control and permission management
- Process isolation
- Rate limiting
MIT