| I was originally thinking of making a Python/Flask or PHP web app that can take form field inputs and then run a subprocess to run the command, with the inputted data as argument values. Eg I can input "microsoft.com" into a form field (or passed in the URL like http://raspi/pingapp/microsoft.com), and the RasPi runs "ping microsoft.com > microsoft.txt" in Raspbian (not that exact command obviously, but it's the best way to explain it). Ideally they'd then see the progress and output of the command in their browser, after submitting. This won't have public access, so auth/security is not a concern. Pretend every user is 100% trusted, and data does not need to be cleaned or checked in any way. I'm open to any language, tool, or framework. I just want it to be as light and reliable as possible. Anyone got any ideas? Thanks. |
If you want to have a preprocessing step, then you need an API to take the commands, process them, run them, and then return the output. If you want to stream the output, you should look into something like websockets. There are also libraries built specifically for streaming logs to the browser, e.g. [0]
But might I suggest a simpler approach? How about a JS terminal emulator that is SSHed into the raspberry pi? I've used a library called "wetty" [1] successfully in the past. It's a node server + JS terminal emulator (based on hterm, used in chromebooks). The node server SSH's into the target box on behalf of the client, and then forwards the tty over the link `client <-> server <-> ssh <-> target`. All you need to do is install the node server on the pi and have it SSH into localhost.
[0] https://github.com/mthenw/frontail
[1] https://github.com/krishnasrinivas/wetty