Minor improvements

This commit is contained in:
Miroslav Stampar
2019-11-14 14:21:53 +01:00
parent aa9ff9e8a6
commit 7e28c02948
6 changed files with 19 additions and 7 deletions

View File

@@ -124,13 +124,14 @@ class ReqHandler(BaseHTTPRequestHandler):
self.url, self.params = path, params
if self.url == '/':
self.send_response(OK)
if "id" not in params:
self.send_response(FOUND)
self.send_header("Content-type", "text/html")
self.send_header("Connection", "close")
self.send_header("Location", "/?id=1")
self.end_headers()
self.wfile.write(b"<html><p><h3>GET:</h3><a href='/?id=1'>link</a></p><hr><p><h3>POST:</h3><form method='post'>ID: <input type='text' name='id'><input type='submit' value='Submit'></form></p></html>")
else:
self.send_response(OK)
self.send_header("Content-type", "text/html")
self.send_header("Connection", "close")