GithubHelp home page GithubHelp logo

joelhoro / pyxterm.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cs01/pyxtermjs

0.0 0.0 0.0 154 KB

A fully functional terminal in your browser.

License: MIT License

Python 67.05% HTML 30.26% Makefile 2.68%

pyxterm.js's Introduction

pyxterm.js

A fully functional terminal in your browser.

screenshot

How does this work?

On the backend:

  • A Flask server is running
  • The Flask server uses flask-socketio, a websocket library for Flask and socketio
  • A pty ("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 is used to render Xterm output data in the browser.
    • This means escape codes 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

Clone this repository, enter the pyxtermjs directory, then run:

python3 -m venv venv  # must be python3.6+
venv/bin/pip install -r requirements.txt
venv/bin/python -m pyxtermjs

Documentation

>> pyxtermjs --help
usage: pyxtermjs [-h] [-p PORT] [--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)
  --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: )

pyxterm.js's People

Contributors

cs01 avatar florianludwig avatar joelhoro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.