{"id":13622666,"url":"https://github.com/cs01/pyxtermjs","last_synced_at":"2025-04-12T20:46:07.619Z","repository":{"id":37237885,"uuid":"147441816","full_name":"cs01/pyxtermjs","owner":"cs01","description":"A fully functional terminal in your browser.","archived":false,"fork":false,"pushed_at":"2024-04-01T23:18:47.000Z","size":167,"stargazers_count":361,"open_issues_count":9,"forks_count":93,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-10-18T21:59:52.726Z","etag":null,"topics":["flask","flask-application","flask-socketio","terminal","terminal-emulators","xterm-js"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cs01.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-05T01:27:15.000Z","updated_at":"2024-10-10T07:30:54.000Z","dependencies_parsed_at":"2024-06-12T03:30:46.809Z","dependency_job_id":null,"html_url":"https://github.com/cs01/pyxtermjs","commit_stats":{"total_commits":32,"total_committers":8,"mean_commits":4.0,"dds":0.28125,"last_synced_commit":"048d6b64872bd09b9fad5067afd750ab83a0e447"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs01%2Fpyxtermjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs01%2Fpyxtermjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs01%2Fpyxtermjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs01%2Fpyxtermjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cs01","download_url":"https://codeload.github.com/cs01/pyxtermjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631701,"owners_count":21136559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","flask-application","flask-socketio","terminal","terminal-emulators","xterm-js"],"created_at":"2024-08-01T21:01:22.470Z","updated_at":"2025-04-12T20:46:07.593Z","avatar_url":"https://github.com/cs01.png","language":"Python","funding_links":[],"categories":["flask","terminal"],"sub_categories":[],"readme":"# pyxterm.js\nA fully functional terminal in your browser.\n\n![screenshot](https://github.com/cs01/pyxterm.js/raw/master/pyxtermjs.gif)\n\n## How does this work?\n\nOn the backend:\n* A [Flask](http://flask.pocoo.org/) server is running\n* The Flask server uses [flask-socketio](https://flask-socketio.readthedocs.io/en/latest/), a websocket library for Flask and socketio\n* A [pty](https://docs.python.org/3/library/pty.html) (\"pseudo-terminal\") is spawned that runs bash.\n  * 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\".\n\nOn the frontend:\n* [Xterm.js](https://xtermjs.org/) is used to render [Xterm](https://en.wikipedia.org/wiki/Xterm) output data in the browser.\n  * 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.\n  * Output from the pty process on the backend is fed into it.\n  * Input from the browser is passed via websocket to the pty's input\n\n\n## Why?\nThe 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.\n\nThis is a\n* starting point to build your own web app with a terminal\n* learning tool to understand what a `pty` is, and how to use one in Python\n* way to see Flask and Flask-SocketIO in action\n* way to play around with Xterm.js in a meaningful environment\n\n## Installation\n\nThere are a few ways to install and run.\n\n### Clone \u0026 Run Locally\nClone this repository, enter the `pyxtermjs` directory.\n\nIf you have [nox](https://github.com/theacodes/nox) you can run the following.\n```\n\u003e nox -s run\n```\nNox takes care of setting up a virtual environment and running the right command for you. You can pass arguments to the server like this\n```\n\u003e nox -s run -- --debug\n```\n\nIf you don't have nox, you can run the following from inside a virtual environment.\n```\n\u003e pip install -r requirements.txt\n\u003e python -m pyxtermjs\n\u003e python -m pyxtermjs --debug\n```\n\n### Install\nYou can install with [pipx](https://github.com/pipxproject/pipx) (recommended) or pip.\n```\n\u003e pipx install pyxtermjs\n\u003e pyxtermjs\n```\n\nOr you can try run latest version on PyPI\n```\n\u003e pipx run pyxtermjs\n```\n\n## API\n```\n\u003e pyxtermjs --help\nusage: pyxtermjs [-h] [-p PORT] [--host HOST] [--debug] [--version]\n                 [--command COMMAND] [--cmd-args CMD_ARGS]\n\nA fully functional terminal in your browser.\nhttps://github.com/cs01/pyxterm.js\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -p PORT, --port PORT  port to run server on (default: 5000)\n  --host HOST           host to run server on (use 0.0.0.0 to allow access\n                        from other hosts) (default: 127.0.0.1)\n  --debug               debug the server (default: False)\n  --version             print version and exit (default: False)\n  --command COMMAND     Command to run in the terminal (default: bash)\n  --cmd-args CMD_ARGS   arguments to pass to command (i.e. --cmd-args='arg1\n                        arg2 --flag') (default: )\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcs01%2Fpyxtermjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcs01%2Fpyxtermjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcs01%2Fpyxtermjs/lists"}