0% found this document useful (0 votes)
98 views1 page

TCL To Python Server Conversion

The server receives HTTP requests from web pages in a specific format like "GET URL HTTP/1.1" and responds accordingly. If the requested file exists, it will respond with "HTTP/1.0 200 OK" followed by the file data. If not found, it will respond with "HTTP/1.0 404 Not found". The server parses the request to extract the desired content, whether it be a file or Modcom command. For files, it checks if the path exists and responds with 200 or 404 status. For commands, it extracts the name and passes it to an Octave script, then sends the script's response to the client.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views1 page

TCL To Python Server Conversion

The server receives HTTP requests from web pages in a specific format like "GET URL HTTP/1.1" and responds accordingly. If the requested file exists, it will respond with "HTTP/1.0 200 OK" followed by the file data. If not found, it will respond with "HTTP/1.0 404 Not found". The server parses the request to extract the desired content, whether it be a file or Modcom command. For files, it checks if the path exists and responds with 200 or 404 status. For commands, it extracts the name and passes it to an Octave script, then sends the script's response to the client.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

TCL to Python Server Conversion

WEB APP Structure

The server sends responses to the HTTP requests comming from the web page.

These requests have a particular format “GET URL HTTP/1.1.”

Example: GET /css/main.css HTTP/1.1.

The response for the request has the following format:

 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

You might also like