4
5 Comments

Simulate terminal in web browser

Hi,

Recently, I have experienced a couple of online courses that let students practice in browser-based command-line interface (CLI).

For example, if I want to practice Docker, I can do that in a CLI on browser rather than having to stall Docker locally.

I’ve been thinking about the architecture of this application, but still not sure what is the best way to implement this or if there is any off-the-shelf service.

I wonder if you’re tasked with building a browser-based CLI which users can interactively access to operating system functions, how would you do it?

Thank you.

on May 15, 2021
  1. 1

    Redis doing something like this on command pages as a playground, have a look at this https://redis.io/commands/hget

    I'd do this with a simple flask app gets a command text from an endpoint and runs it in a container that has the required environment. That's just the first thing comes to my mind

    1. 1

      I think this repo is also helpful to create pseudo terminal:

      https://github.com/microsoft/node-pty

      It's javascript out the box. I will dig into how to use it with other languages.

    2. 1

      I've found this project hat build terminal app with HTML/CSS/Javascript

      https://hyper.is/

      But of course it definitely needs some hacking to make things work.

    3. 1

      Thanks for your reply. The big problem is how to get the response from shell when a user sends a request. Most of the information I've found is about how to style the frontend so it looks like a CLI