It is quite complicated to do this properly, generating an html page with a form and using a proper POST request, perhaps even with authorisation by password. Provided you are on a local network and do not mind anyone connecting, you can get someway towards a demonstration of what could be done with a simple shell script using socat to manage the connection.
Create a shell script, say /tmp/myscript with contents
#!/bin/bash
echo "HTTP/1.0 200 OK
Content-Type: text/plain
running command" |
sed 's/$/\r/'
if echo mycommand >/dev/tcp/127.0.0.1/1234
then echo OK
else echo fail
fi
date
Don't forget to make it executable with chmod +x /tmp/myscript. Then run
socat tcp-listen:8001,reuseaddr,fork exec:/tmp/myscript
and you should be able to connect your browser to http://yourhostname:8001/
to trigger the command. Or for your testing use curl -v http://localhost:8001/
and you should see something like
* Connected to localhost (127.0.0.1) port 8001 (#0)
> GET / HTTP/1.1
> Host: localhost:8001
> User-Agent: curl/7.43.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Content-Type: text/plain
<
running command
OK
Wed Aug 23 21:04:47 CEST 2017
This is less than perfect, as some browsers may cache the result and not actually connect, hence the date output as a check. By using port 8001 you do not need to run socat as root. If you want to use the usual server port 80 (so your url is just http://yourhostname) you need to do sudo socat ....
If you are familiar with python, ruby, perl or many other languages, they all provide simple web servers that can handle POST requests correctly.