A fully functional terminal in your browser.
On the backend:
On the frontend:
The real purpose of this is to show a basic proof of concept on how to bring Xterm.js, Python, Flask, and Websockets together to run a pty in the browser.
This is a
pty
is, and how to use one in PythonThere are a few ways to install and run.
Clone this repository, enter the pyxtermjs
directory.
If you have nox you can run the following.
> nox -s run
Nox takes care of setting up a virtual environment and running the right command for you. You can pass arguments to the server like this
> nox -s run -- --debug
If you don't have nox, you can run the following from inside a virtual environment.
> pip install -r requirements.txt
> python -m pyxtermjs
> python -m pyxtermjs --debug
You can install with pipx (recommended) or pip.
> pipx install pyxtermjs
> pyxtermjs
Or you can try run latest version on PyPI
> pipx run pyxtermjs
> pyxtermjs --help
usage: pyxtermjs [-h] [-p PORT] [--host HOST] [--debug] [--version]
[--command COMMAND] [--cmd-args CMD_ARGS]
A fully functional terminal in your browser.
https://github.com/cs01/pyxterm.js
optional arguments:
-h, --help show this help message and exit
-p PORT, --port PORT port to run server on (default: 5000)
--host HOST host to run server on (use 0.0.0.0 to allow access
from other hosts) (default: 127.0.0.1)
--debug debug the server (default: False)
--version print version and exit (default: False)
--command COMMAND Command to run in the terminal (default: bash)
--cmd-args CMD_ARGS arguments to pass to command (i.e. --cmd-args='arg1
arg2 --flag') (default: )