4 ms·
Question: Any suggestions on some easy ways to make a web page which displays a status value, where the status is updated by a simple shell command? You mention
by TaylorAlexander 4y ago
Question:
Any suggestions on some easy ways to make a web page which displays a status value, where the status is updated by a simple shell command? You mention pinging a URL with sensor values, which seems similar to what I want to do (which is to see if a remote location has power and internet connectivity or not, so I don't bother driving to work if the power is out).
- Donckele 4y agoIf the script is local to the web server then it can be run via cron to produce html/js/css files. If the script is external then it must be capable of making a http request to the server where a script does something similar to the scenario above.
- TaylorAlexander 4y agoYeah. I have a couple servers I could maybe run something on. I guess I don’t really know how to serve a link where I could make an HTTP request. I run servers with discourse and other applications but I never manually serve something. I suppose this is simple enough and I should look that up. What is it called on the server side when you make a URL available for receiving HTTP requests? I realize I’m not sure what to research exactly. EDIT: wait a minute, actually I’ve used flask before with python. I guess I just need to figure out how to run flask on my web server, maybe on a sub domain, without interfering with the discourse instance that’s already there. Hmmm.
- Donckele 4y agoYep, a simple flask app is an option. Easy to deploy and have a simple endpoint hook that reads the input parameters and then does your magic of writing out some static files and/or if you feel adventurous write out json files that can be read via javascript!
- jcynix 4y agoKnowledge of plain old CGI on a web server seems lost due to fancy frameworks? And even without the CGI-Interface, you can make it work if you have a script monitoring your web server's logs: I sometimes transfer data with curl via a url which does not exist, but where a script running on the server watches the server's error log and extracts data from those entries. For example: access (via curl or perl' GET, or whatever) these urls http://my-server/data0815/up+2 http://my-server/data0815/up+2 http://my-server/data0815/down-3 http://my-server/data0815/down-3 The script watches for these entries and acts upon the stuff following the data0815 part. It's a fast hack, which can be augmented and expanded in various ways, all without frameworks.
- TaylorAlexander 4y ago> Knowledge of plain old CGI on a web server seems lost due to fancy frameworks? eh I just never learned it. I'm a robotics engineer and I tend to write programs in Python (or less commonly now, C++) to run in a loop and deal with local hardware. The way that web servers operate in a stateless multithreaded way involves some peculiarities that I always find a little tricky. > I sometimes transfer data with curl via a url which does not exist, but where a script running on the server watches the server's error log and extracts data from those entries. Hey that's a nice trick! I already have a server running discourse. Maybe I can sneak something in there. Though it looks like someone's suggestion of https://healthchecks.io/ https://healthchecks.io/ might do what I need.
- lioeters 4y ago> What is it called on the server side when you make a URL available for receiving HTTP requests? This fits the definition of API (application programming interface). For a single API endpoint to post data, I would personally write a little Node.js script using built-in HTTP module or Express. For Python, maybe something like this: https://pythonbasics.org/flask-rest-api/ https://pythonbasics.org/flask-rest-api/
- seba_dos1 4y agoSounds like a few lines of code in whichever framework is trendy among webdevs these days.
- onion2k 4y agoYou mention pinging a URL with sensor values, which seems similar to what I want to do (which is to see if a remote location has power and internet connectivity or not, so I don't bother driving to work if the power is out). You don't need a fancy wireless weather station for that. Just put a tiny server at the remote location. If you can't ping it then the power or internet is out, and you can stay at home.
- TaylorAlexander 4y agoI’m not using a wireless weather station. I’m just asking about the web design part. But I want to be able to check a web page with my phone, not use ping. Also the site uses starlink so there’s no static IP, so I’d have to log in to tailscale and that’s even more fiddling.
- moritonal 4y agonode-red, along with the dashboard extension[1] would serve a HTTP server that could have many inputs, such as a shell command. You'd run that on a server, not the client. 1. https://flows.nodered.org/node/node-red-dashboard https://flows.nodered.org/node/node-red-dashboard
- willy_k 4y agoNot in the same vein as the discussion, but something as simple as a Pi pinging https://healthchecks.io/ https://healthchecks.io/ or a similar tool could work well for your needs.
- TaylorAlexander 4y agoOh hey that’s perfect! I really didn’t want to set up a whole server. This looks nice thank you!