#deal wiht GET method if method == 'GET': if src == '/index.html': content = index_content elif src == '/T-mac.jpg': content = pic_content elif src == '/reg.html': content = reg_content elif re.match('^/\?.*$', src): entry = src.split('?')[1] # main content of the request content = 'HTTP/1.x 200 ok\r\nContent-Type: text/html\r\n\r\n' content += entry content += '<br /><font color="green" size="7">register successs!</p>' else: continue
#deal with POST method elif method == 'POST': form = request.split('\r\n') entry = form[-1] # main content of the request content = 'HTTP/1.x 200 ok\r\nContent-Type: text/html\r\n\r\n' content += ent