aboutsummaryrefslogtreecommitdiffstats
path: root/csci4131
diff options
context:
space:
mode:
authorRossTheRoss <mstrapp@protonmail.com>2021-03-07 16:07:18 -0600
committerRossTheRoss <mstrapp@protonmail.com>2021-03-07 16:07:18 -0600
commita4025bdd77db1fe17ed8388e33ef003d6c7d8999 (patch)
tree4c10b1e91e427b49ef3859592b686827ee2099ab /csci4131
parentM (diff)
downloadhomework-a4025bdd77db1fe17ed8388e33ef003d6c7d8999.tar
homework-a4025bdd77db1fe17ed8388e33ef003d6c7d8999.tar.gz
homework-a4025bdd77db1fe17ed8388e33ef003d6c7d8999.tar.bz2
homework-a4025bdd77db1fe17ed8388e33ef003d6c7d8999.tar.lz
homework-a4025bdd77db1fe17ed8388e33ef003d6c7d8999.tar.xz
homework-a4025bdd77db1fe17ed8388e33ef003d6c7d8999.tar.zst
homework-a4025bdd77db1fe17ed8388e33ef003d6c7d8999.zip
Fix the screwyness
Diffstat (limited to 'csci4131')
-rw-r--r--csci4131/hw4/strap012/strap012.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/csci4131/hw4/strap012/strap012.py b/csci4131/hw4/strap012/strap012.py
index ff55926..d6d6385 100644
--- a/csci4131/hw4/strap012/strap012.py
+++ b/csci4131/hw4/strap012/strap012.py
@@ -9,21 +9,23 @@ from argparse import ArgumentParser
BUFSIZE = 4096
CRLF = '\r\n'
METHOD_NOT_ALLOWED = 'HTTP/1.1 405 METHOD NOT ALLOWED{}Allow: GET, HEAD, POST {}Connection: close{}{}'.format(CRLF, CRLF, CRLF, CRLF)
-OK = 'HTTP/1.1 200 OK{}{}{}'.format(CRLF, CRLF, CRLF) # head request only
+OK = 'HTTP/1.1 200 OK{}{}'.format(CRLF, CRLF, CRLF) # head request only
def getContents(type, file):
returnValue = "".encode()
try:
content = open(file, 'rb')
except FileNotFoundError:
- getContents(type, "404.html")
+ returnValue = getContents(type, "404.html")
except PermissionError:
- getContents(type, "403.html")
+ returnValue = getContents(type, "403.html")
else:
if type == "HEAD" or "GET":
returnValue = OK.encode()
if type == "GET":
- returnValue =b"".join([returnValue, content.read(), "{}{}".format(CRLF, CRLF).encode()])
+ returnValue = b"".join([returnValue, content.read(), "{}{}".format(CRLF, CRLF).encode()])
+ else:
+ returnValue = b"".join([returnValue, "{}{}".format(CRLF, CRLF).encode()])
elif type == "POST":
print("B")
else: