かんたん作成【HTML CSS JavaScript PHP CGI Perl Ruby Python .htaccess】

URL取得・表示(os.environ['HTTP_HOST'], os.environ['REQUEST_URI'])

#! /usr/bin/python
# coding: Shift_JIS

import os

url = ""

if os.environ.has_key('HTTP_HOST') and os.environ.has_key('REQUEST_URI'):
    url = "https://" + os.environ['HTTP_HOST'] + os.environ['REQUEST_URI']

print "Content-type: text/html"
print """
    <html>
    <head>
    <title>URL取得・表示</title>
    </head>
    <body>
    %s<br>
    </body>
    </html>
""" % url
かんたん作成【HTML CSS JavaScript PHP CGI Perl Ruby Python .htaccess】