Skip to content
This repository has been archived by the owner on Aug 12, 2021. It is now read-only.

Commit

Permalink
Update Python webserver to handle '/page/*' urls
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Jan 25, 2016
1 parent f5daf20 commit 6396ffa
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions py/test/selenium/webdriver/common/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ def do_GET(self):
"""GET method handler."""
try:
path = self.path[1:].split('?')[0]
html = open(os.path.join(HTML_ROOT, path), 'r', encoding='latin-1')
if path[:4] == "page":
html = """<html><head><title>Page{page_number}</title></head>
<body>Page number <span id=\"pageNumber\">{page_number}</span>
<p><a href=\"../xhtmlTest.html\" target=\"_top\">top</a>
</body></html>""".format(page_number=path[5:])
else:
with open(os.path.join(HTML_ROOT, path), 'r', encoding='latin-1') as f:
html = f.read().encode('utf-8')
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(html.read().encode('utf-8'))
html.close()
self.wfile.write(html)
except IOError:
self.send_error(404, 'File Not Found: %s' % path)

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

if __name__ == "__main__":
main()


0 comments on commit 6396ffa

Please sign in to comment.