TCL To Python Server Conversion
TCL To Python Server Conversion
The server sends responses to the HTTP requests comming from the web page.
if the server has the desired file, it will send "HTTP/1.0 200 OK\r\n" and after that the data
from that file will be send. (Observation: the server can send the length of the text. This can
help the web page client to wait for the entire message. Lenght of the message is calculated
in bytes. "Content-Length: $len_bytes \r\n\r\n", „\r\n\r\n” – means the end of the header.
if the server doesn’t have the requested files or the format of the command is wrong, so the
web page client will receive and error message: "HTTP/1.0 404 Not found\r\n"
The server parses the request and extracts the desired content. This content can be a file or a
Modcom CMD.
FILE – the server checks if the path for that file exists
o answer to the client with HTTP/1.0 200 OK or HTTP/1.0 404 Not found
Modcom CMD – this command is extracted from the file and it is sent to the octave script
using the stdout channel. Example:
o „GET /modcom_webapi/top/get/version HTTP/1.1.”
o the server extracts the name of the URL - /modcom_webapi/top/get/version it
will generate the following cmd for the octave script. (split the string by „/”) -
MODCOM-WEB-API: top get version
o The server is waiting for the Octave answer on stdin.
o The server sends the anwser to the client using HTTP protocol