#!/usr/bin/env python3

import os

print("Content-type: text/html")
print()   # må ha tom linje mellom HTTP Headers og Body

start = """\
<html>
<head>
  <meta charset="utf-8">
  <title>Hello World</title>
</head>
<body>
  <h1>Here's how we get information:</h1>
"""

end = """\
</body>
</html>
"""


print(start)

print("info goes here")

#print("<pre>")
#
#for k,v in os.environ.items():
#	print(k,' : ',v)
#	
#print("</pre>")

path = os.getenv("PATH_INFO")

split_path = path.split('/')
greeting = split_path[1]
name = split_path[2]

print("here: <br>")

if greeting == "hello":

    print(greeting,name)

else:

    print("You didn't say hello!")

    print(f'<a href="/cgi-bin/how.cgi/hello/{name}">Use this instead</a>')


print(end)
