You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using --output json with CLI_APP to say that the CLI_APP will output json (for REST API).
Here, --output web with ADD_UI will add HTML, CSS, JS etc. to the JSON output.
I am using ADD_HTTP_RESPONSE_MESSAGE to add HEADERS, response code etc. This is because, I want the CLI apps to be totally independent. I do not want to add HTTP response message to CLI_APP or ADD_UI output so that I can reuse these tools in case I decide to make a GUI app or mobile app or something later where HTTP is not involved.
Question:
I think websocketd is the solution of my problem. am I right? Or am i missing something?
In your example codes you did not print any HTTP header or status code, so I assume you deal with the http stuff, and we just print to stdout. I mean, I will not need ADD_HTTP_RESPONSE_MESSAGE. Will it be a correct statement?
In your examples, I did not find how to deal with GET or POST requests. In CGI, we use QUERY_STRING to get data from GET request and then parse it. For, POST, the data is sent as input stream to the program. since the server passes information to this program as an input stream, it sets the environment variable CONTENT_LENGTH to the size of the data in number of bytes (or characters). We can use this to read exactly that much data from standard input. How to deal with GET and POST request in websocketd.
In the count example, there is count.html. It calls ./count.sh via var ws = new WebSocket('ws://localhost:8080/');. So, first we are getting the HTML file, it is calling the sh file. But I want to first hit ./count.sh and it will generate the count.html file. Is it possible?
How to pipe multiple commands to get the output. For example, how can I get the output of ps -ef | grep root | wc -l using websocketd?
The text was updated successfully, but these errors were encountered:
Problem Description:
I am working on a solution to pipe multiple CLI apps to generate a website.
In Linux terms, it will look like:
I am using
--output json
withCLI_APP
to say that theCLI_APP
will output json (for REST API).Here,
--output web
withADD_UI
will add HTML, CSS, JS etc. to the JSON output.I am using
ADD_HTTP_RESPONSE_MESSAGE
to add HEADERS, response code etc. This is because, I want the CLI apps to be totally independent. I do not want to add HTTP response message to CLI_APP or ADD_UI output so that I can reuse these tools in case I decide to make a GUI app or mobile app or something later where HTTP is not involved.Question:
I think
websocketd
is the solution of my problem. am I right? Or am i missing something?In your example codes you did not print any HTTP header or status code, so I assume you deal with the http stuff, and we just print to stdout. I mean, I will not need
ADD_HTTP_RESPONSE_MESSAGE
. Will it be a correct statement?In your examples, I did not find how to deal with GET or POST requests. In CGI, we use
QUERY_STRING
to get data from GET request and then parse it. For, POST, the data is sent as input stream to the program. since the server passes information to this program as an input stream, it sets the environment variableCONTENT_LENGTH
to the size of the data in number of bytes (or characters). We can use this to read exactly that much data from standard input. How to deal with GET and POST request in websocketd.In the count example, there is
count.html
. It calls./count.sh
viavar ws = new WebSocket('ws://localhost:8080/');
. So, first we are getting the HTML file, it is calling the sh file. But I want to first hit./count.sh
and it will generate thecount.html
file. Is it possible?How to pipe multiple commands to get the output. For example, how can I get the output of
ps -ef | grep root | wc -l
usingwebsocketd
?The text was updated successfully, but these errors were encountered: