Skip to content

Commit 6396ffa

Browse files
Update Python webserver to handle '/page/*' urls
1 parent f5daf20 commit 6396ffa

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

py/test/selenium/webdriver/common/webserver.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,18 @@ def do_GET(self):
5555
"""GET method handler."""
5656
try:
5757
path = self.path[1:].split('?')[0]
58-
html = open(os.path.join(HTML_ROOT, path), 'r', encoding='latin-1')
58+
if path[:4] == "page":
59+
html = """<html><head><title>Page{page_number}</title></head>
60+
<body>Page number <span id=\"pageNumber\">{page_number}</span>
61+
<p><a href=\"../xhtmlTest.html\" target=\"_top\">top</a>
62+
</body></html>""".format(page_number=path[5:])
63+
else:
64+
with open(os.path.join(HTML_ROOT, path), 'r', encoding='latin-1') as f:
65+
html = f.read().encode('utf-8')
5966
self.send_response(200)
6067
self.send_header('Content-type', 'text/html')
6168
self.end_headers()
62-
self.wfile.write(html.read().encode('utf-8'))
63-
html.close()
69+
self.wfile.write(html)
6470
except IOError:
6571
self.send_error(404, 'File Not Found: %s' % path)
6672

@@ -142,5 +148,3 @@ def main(argv=None):
142148

143149
if __name__ == "__main__":
144150
main()
145-
146-

0 commit comments

Comments
 (0)