'Is there a way to get httpd to serve a simple string?
The question says it all. I am running a simple test and want to see the output over the localhost.
Is it possible to use httpd (https://boxmatrix.info/wiki/Property:httpd) to accomplish this task?
In other words
busybox httpd -f -p 8000
will give me its standard output, but I would like to see a string or something.
If not, what is the easiest way to accomplish this task?
Solution 1:[1]
Sorry, it's not clear if you want to serve some string or to receive (i.e some API call?).
The busybox httpd -f -p 8000
command starts the http server on port 8000 on all interfaces (including public) but don't go to background and you see logs of the server.
If you want to serve a string then you can create an index.html file and put the string there. The bb httpd will show the content of the index.html file by default when you open the site in browser.
If the string should be dynamically taken from somewhere then you have to create a CGI script.
Create a file ./cgi-bin/index.cgi
, add a shebang and printf "Content-Type: plain/text\r\n\r\nsome string"
and then make it executable. After opening the site the script will be executed and it's output will be returned to a browser.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sergey Ponomarev |