def do_POST(self):
# How long was the post data?
length = int(self.headers.get('Content-length', 0))
# Read and parse the post data
data = self.rfile.read(length).decode()
yourname = parse_qs(data)["yourname"][0]
# Create cookie.
c = cookies.SimpleCookie()
c['yourname'] = yourname
c['yourname']['domain'] = 'localhost'
c['yourname']['max-age'] = 60
# Send a 303 back to the root page, with a cookie!
self.send_response(303) # redirect via GET
self.send_header('Location', '/')
self.send_header('Set-Cookie', c['yourname'].OutputString())
self.end_headers()
评论列表
文章目录