Heimbs 5 years ago
parent
commit
4cbf4fd861
1 changed files with 8 additions and 8 deletions
  1. 8
    8
      http-server

+ 8
- 8
http-server View File

@@ -15,18 +15,18 @@ class SimpleHandler(server.BaseHTTPRequestHandler):
query_components = parse.parse_qsl(query)

if path == "/":
msg = self.return_get_components(path, query, query_components)
msg = self.get_components(path, query, query_components)
elif path == "/ying":
msg = self.return_ying()
msg = self.get_ying()
elif path == "/yang":
msg = self.return_yang()
msg = self.get_yang()
elif path == "/squares":
msg = self.return_squares(query_components)
msg = self.get_squares(query_components)
else:
msg = "Error 404"
self.wfile.write(msg.encode('utf-8'))

def return_squares(self, query_components):
def get_squares(self, query_components):
if len(query_components) != 2:
msg = "Invalid number of Query Components! Two components needed."
else:
@@ -47,15 +47,15 @@ class SimpleHandler(server.BaseHTTPRequestHandler):
return msg

def return_ying(self):
def get_ying(self):
msg = "<a href='/yang'>Ying</a>"
return msg
def return_yang(self):
def get_yang(self):
msg = "<a href='/ying'>Yang</a>"
return msg
def return_get_components(self, path, query, query_components):
def get_components(self, path, query, query_components):
msg = f"Path: {path}\nQuery: {query}\nComponents: {str(query_components)}"
return msg


Loading…
Cancel
Save