Terminal window built into a website

I am researching how to run a terminal window (like the ones on Codecademy), and embed it into a personal website. Is this considered an API?

I have the Python code to run in the terminal, but looking for suggestions on how to “embed” the terminal into the HTML file.

So far I’ve found the “cgitb” library, but that doesn’t get me anywhere near what I’m trying to accomplish.

Any ideas or pointers in the right direction are appreciated. :slight_smile:

Hmm web dev is not my forte but perhaps-

might be along the lines of what you’re looking for. It depends a little on what this terminal is supposed to do really (so far as I’m aware that’s just the frontend). Running an actual program for this would to interact with need back and forth with a server that’d be more tricky (doing that locally is one thing, for a public facing website that might not be trivial). Kinda speculating by this point though, hopefully there are libraries for this purpose. Happy to be corrected anyway but give xterm.js a look-in as I think it’s pretty common (or might at least lead you to alternatives).

Thanks for sharing Xtrem.js, seems pretty straight forward until navigating around NPM. But I’ll try out the scripts and see how it works.

Basically I’m looking for a way to have

terminal
that can act as a terminal to run small python script.

This is for a personal portfolio, to show scripts written, but not show the code, just be interactive.

Totally in the dark, but,

would this not imply that Python is installed on the client?

It is very possible I am over my head and trying to complete something I haven’t learned yet… but still trying.
Here’s what I’m trying to achieve, have three difference

sections, each of which display a “terminal-like” environment, that runs the python program. These are extremely simple python script that take user input and run a simple program, like ATM script.

1 Like

In all likelihood, it would take some consultation with an engineer who could advise on how to embed the Python environment in a web page so the client doesn’t need it. One would also want to pay very close attention to security concerns so the client cannot be used as a vector for malicious attacks. Still, only speculating at what concerns there would be.

2 Likes

The problem with something like Python is you need an active Python virtual machine to interpret the code; since it’s not natively supported by a normal web browser this typically means hosting something (networking). So do you host a server to deal with these requests to run a script, or, do you expect your user to install the same version of Python and enable a large degree of access from a random website (security?).

Like I say I’m pretty naive when it comes to web-dev but I can’t spot a simple solution to this (aside from mimicry). If you expect users to be willing to use your code then providing the code directly (hosting a repository e.g. bitbucker, github, gitlab) might be better. Hosting a server to actually run code might be troublesome, hosting one locally may be a nightmare… Something like heroku might be a viable small scale alternative (or look for similar options).

2 Likes