#!/usr/bin/env python
# -*- coding: utf-8 -*- 
# predoslom riadku je deklaracia kodovania
import sys
import cgi
import os
import cgitb
cgitb.enable()


response="""
<html>
<head>
    <title>
        Testovací skript
    </title>
</head>
<body>
"""

response+="""
<h2>
    CGI parametre
</h2>
<p>
    <table>
"""

params=cgi.FieldStorage()

for key in params:
    response+="""
        <tr>
            <td>
                %s
            </td>
            <td>
                %s
            </td>
        </tr>
""" % (key,params[key].value)

response+="""
    </table>
</p>
<h2>
    Prostredie
</h2>
    <table>
"""
for key in os.environ:
    response+="""
        <tr>
            <td>
                %s
            </td>
            <td>
                %s
            </td>
        </tr>
""" % (key,os.environ[key])
response+="""
    </table>
</p>
</body>
"""
    
sys.stdout.write("Content-type: text/html; charset=UTF-8\r\n")
sys.stdout.write("Content-length: %d\r\n" % len(response))
sys.stdout.write("\r\n")
sys.stdout.write(response)
