first commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Chad Smith
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,114 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: pyxtermjs
|
||||
Version: 0.5.0.2
|
||||
Summary: interactive terminal in the browser
|
||||
Home-page: https://github.com/cs01/pyxtermjs
|
||||
Author: Chad Smith
|
||||
Author-email: chadsmith.software@gmail.com
|
||||
License: License :: OSI Approved :: MIT License
|
||||
Keywords: xterm,xterm.js,javascript,terminal-emulators,browser,tty,pty,console,terminal
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Programming Language :: Python :: 3.7
|
||||
Classifier: Programming Language :: Python :: 3 :: Only
|
||||
Requires-Python: >=3.6
|
||||
Description-Content-Type: text/markdown
|
||||
License-File: LICENSE
|
||||
Requires-Dist: bidict (==0.21.2)
|
||||
Requires-Dist: click (==8.0.1)
|
||||
Requires-Dist: flask (==2.0.1)
|
||||
Requires-Dist: flask-socketio (==5.1.1)
|
||||
Requires-Dist: itsdangerous (==2.0.1)
|
||||
Requires-Dist: jinja2 (==3.0.1)
|
||||
Requires-Dist: markupsafe (==2.0.1)
|
||||
Requires-Dist: python-engineio (==4.2.1)
|
||||
Requires-Dist: python-socketio (==5.4.0)
|
||||
Requires-Dist: werkzeug (==2.0.1)
|
||||
|
||||
# pyxterm.js
|
||||
A fully functional terminal in your browser.
|
||||
|
||||

|
||||
|
||||
## How does this work?
|
||||
|
||||
On the backend:
|
||||
* A [Flask](http://flask.pocoo.org/) server is running
|
||||
* The Flask server uses [flask-socketio](https://flask-socketio.readthedocs.io/en/latest/), a websocket library for Flask and socketio
|
||||
* A [pty](https://docs.python.org/3/library/pty.html) ("pseudo-terminal") is spawned that runs bash.
|
||||
* You can think of a pty as a way to serialize/deserialize a terminal session. The Python docs describe it as "starting another process and being able to write to and read from its controlling terminal programmatically".
|
||||
|
||||
On the frontend:
|
||||
* [Xterm.js](https://xtermjs.org/) is used to render [Xterm](https://en.wikipedia.org/wiki/Xterm) output data in the browser.
|
||||
* This means [escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) used by terminals to control the cursor location, color, and other options can be passed directly to Xterm.js and Xterm.js will faithfully render them as a terminal would.
|
||||
* Output from the pty process on the backend is fed into it.
|
||||
* Input from the browser is passed via websocket to the pty's input
|
||||
|
||||
|
||||
## Why?
|
||||
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
|
||||
* starting point to build your own web app with a terminal
|
||||
* learning tool to understand what a `pty` is, and how to use one in Python
|
||||
* way to see Flask and Flask-SocketIO in action
|
||||
* way to play around with Xterm.js in a meaningful environment
|
||||
|
||||
## Installation
|
||||
|
||||
There are a few ways to install and run.
|
||||
|
||||
### Clone & Run Locally
|
||||
Clone this repository, enter the `pyxtermjs` directory.
|
||||
|
||||
If you have [nox](https://github.com/theacodes/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
|
||||
```
|
||||
|
||||
### Install
|
||||
You can install with [pipx](https://github.com/pipxproject/pipx) (recommended) or pip.
|
||||
```
|
||||
> pipx install pyxtermjs
|
||||
> pyxtermjs
|
||||
```
|
||||
|
||||
Or you can try run latest version on PyPI
|
||||
```
|
||||
> pipx run pyxtermjs
|
||||
```
|
||||
|
||||
## API
|
||||
```
|
||||
> 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: )
|
||||
|
||||
```
|
||||
@@ -0,0 +1,16 @@
|
||||
../../../bin/pyxtermjs,sha256=P2_Bw9Tz9wFFpxf40DQ9MoqVqwF86uWzbTf31EgOzJ0,232
|
||||
pyxtermjs-0.5.0.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
pyxtermjs-0.5.0.2.dist-info/LICENSE,sha256=8DDF5BiCha22nQ5H0LQpnoIUgikINzuvcJos6HkyUXY,1067
|
||||
pyxtermjs-0.5.0.2.dist-info/METADATA,sha256=ITq9odpM4bV8VLvlR7xVNUhKDJABFjE9NHXqlGNTwrs,4367
|
||||
pyxtermjs-0.5.0.2.dist-info/RECORD,,
|
||||
pyxtermjs-0.5.0.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
pyxtermjs-0.5.0.2.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
||||
pyxtermjs-0.5.0.2.dist-info/entry_points.txt,sha256=V5zLlX9cgfNZJkp1DdqBIAvliER1f-AA_9FYqf0yiHM,49
|
||||
pyxtermjs-0.5.0.2.dist-info/top_level.txt,sha256=tmKzZJ8UvB0e0UFjfnTgIpVifCI1OG4ZXvfMRsBtI1A,10
|
||||
pyxtermjs/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
|
||||
pyxtermjs/__main__.py,sha256=KjxEL8LczSq3duSPsT2TQhNu45UOuxbl4xrUkxQOY3o,68
|
||||
pyxtermjs/__pycache__/__init__.cpython-311.pyc,,
|
||||
pyxtermjs/__pycache__/__main__.cpython-311.pyc,,
|
||||
pyxtermjs/__pycache__/app.cpython-311.pyc,,
|
||||
pyxtermjs/app.py,sha256=w_jIO3Y5L_Ls-GxLFtALw_PumKAuY2qNzb0RB0Bdemg,4789
|
||||
pyxtermjs/index.html,sha256=6wxfnCgtaE8o-mzgXaht2_wW8YGj3-lZ9sTAQO9U2Uk,4649
|
||||
@@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.37.1)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
[console_scripts]
|
||||
pyxtermjs = pyxtermjs.app:main
|
||||
@@ -0,0 +1 @@
|
||||
pyxtermjs
|
||||
Reference in New Issue
Block a user