Skip to content

Commit 23060bd

Browse files
committed
lesson03 assignment submission
1 parent 9257c73 commit 23060bd

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

http_server.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def response_method_not_allowed():
4343
def response_not_found():
4444
"""Returns a 404 response Not Found """
4545

46-
4746
return b"\r\n".join([
4847
b"HTTP/1.1 404 Request Not Found response",
4948
b"",
@@ -95,23 +94,20 @@ def response_path(path):
9594
"""
9695

9796
# path = "webroot" + path
98-
# path was "/a_web_page.html"
9997
path = os.path.join("webroot", path.strip('/'))
10098

101-
# now path is "webroot/a_web_page.html"
102-
103-
# IF the path points to a file eg: webroot/a_web_page.html
99+
# If the path points to a file eg: webroot/a_web_page.html
104100
if os.path.isfile(path):
105101
with open(path, "rb") as f:
106102
content = f.read()
107103
mime_type = mimetypes.guess_type(path)[0].encode()
108104

109-
# IF the path points to a directoty eg: webroot/images
105+
# If the path points to a directoty eg: webroot/images
110106
elif os.path.isdir(path):
111107
content = " ".join(os.listdir(path)).encode()
112108
mime_type = b"text/plain"
113109

114-
# IF the path points to a non_existing eg: webroot/asdfoo.html
110+
# If the path points to a non_existing eg: webroot/asdfoo.html
115111
else:
116112
raise NameError
117113

tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def test_root_index(self):
190190

191191
def test_ok_response_at_root_index(self):
192192
"""
193-
A call to / at least yields a 200 OK response
193+
A call to / at least yields a 200 OK response
194194
"""
195195

196196
directory = ''

0 commit comments

Comments
 (0)