I am building a web with a web server and Python. As you build, you may create new pages and merge old pages. If a visitor has bookmarked a page, you must notify the visitor that the address has changed.
So there is a way to redirect from the old page to the new page.
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import cgi
form = cgi.FieldStorage()
all_query = '?'
for key in form:
all_query = all_query \
+ key \
+ '=' \
+ form[key].value + '&'
all_query = all_query[0:len(all_query) - 1]
print ('content-type: text/html; charset=UTF-8\n')
html_body = """\
<html><body>
<script>
window.location = '/any.py{0}';
</script>
</body></html>
""".format(all_query)
print (html_body)
Now you don't have to ask to change your bookmarks.
Recommended Posts