test-platform/server/index.py

23 lines
530 B
Python
Raw Normal View History

2024-05-25 19:18:26 +03:00
import sys
import os
2024-05-28 17:47:08 +03:00
#print(f"PWD: {os.getcwd()}", file=sys.stderr)
2024-05-25 19:18:26 +03:00
2024-05-28 17:47:08 +03:00
#print(f"Environ: {os.environ}", file=sys.stderr)
2024-05-25 19:18:26 +03:00
sys.path.insert(0, "/root/ipz-server-1/server/cgi/")
from view import View
from httputils import parse_query
query_dict = parse_query(os.environ['QUERY_STRING'])
view = View(query_dict)
html_page = view.render_page()
page_length = len(html_page.encode("UTF-8"))
print(f"Content-Type: text/html; charset=UTF-8\r\n" + \
f"Content-Length: {page_length}\r\n" + \
f"\r\n" + \
f"{html_page}")