aboutsummaryrefslogtreecommitdiffstats
path: root/csci4131/hw4/strap012
diff options
context:
space:
mode:
authorMatthew Strapp <msattr@gmail.com>2021-03-09 09:17:25 -0600
committerMatthew Strapp <msattr@gmail.com>2021-03-09 09:17:25 -0600
commit77c816f75eccd477958ae150f6bab4e1fa947f3e (patch)
treec3b820fb16dc5b181b217abf0f69eb578169c328 /csci4131/hw4/strap012
parentrearrange (diff)
downloadhomework-77c816f75eccd477958ae150f6bab4e1fa947f3e.tar
homework-77c816f75eccd477958ae150f6bab4e1fa947f3e.tar.gz
homework-77c816f75eccd477958ae150f6bab4e1fa947f3e.tar.bz2
homework-77c816f75eccd477958ae150f6bab4e1fa947f3e.tar.lz
homework-77c816f75eccd477958ae150f6bab4e1fa947f3e.tar.xz
homework-77c816f75eccd477958ae150f6bab4e1fa947f3e.tar.zst
homework-77c816f75eccd477958ae150f6bab4e1fa947f3e.zip
Fix some small errors, begin to implement POST
Diffstat (limited to '')
-rw-r--r--csci4131/hw4/strap012/strap012.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/csci4131/hw4/strap012/strap012.py b/csci4131/hw4/strap012/strap012.py
index df63e4f..43b7efb 100644
--- a/csci4131/hw4/strap012/strap012.py
+++ b/csci4131/hw4/strap012/strap012.py
@@ -20,6 +20,11 @@ def check_perms(resource):
stmode = os.stat(resource).st_mode
return(getattr(stat, 'S_IROTH') & stmode) > 0
+def POST(form):
+ contents = form.decode(utf-8)
+ print(contents)
+ return
+
def getContents(type, file):
returnValue = "".encode()
try:
@@ -45,7 +50,9 @@ def getContents(type, file):
returnValue = b"".join(
[returnValue, content.read(), "{}{}".format(CRLF, CRLF).encode()])
elif type == "POST":
- print("B")
+ POST(content.read())
+ #returnValue = b"".join(
+ # [returnValue, POST(content.read(), "{}{}".format(CRLF, CRLF).encode())])
else:
returnValue= METHOD_NOT_ALLOWED.encode()
content.close()
@@ -55,12 +62,12 @@ def client_recv(client_sock, client_addr):
print('talking to {}'.format(client_addr))
data = client_sock.recv(BUFSIZE)
data = data.decode('utf-8').strip("\r")
+ print(data)
data = data.split("\n")
request = data[0].split(" ")
- if len(data) != 0:
+ if len(request) > 1:
want = getContents(request[0], request[1][1:])
client_sock.send(want)
- print(want)
client_sock.shutdown(1)
client_sock.close()