aboutsummaryrefslogtreecommitdiffstats
path: root/csci4131/hw4/strap012
diff options
context:
space:
mode:
authorRossTheRoss <mstrapp@protonmail.com>2021-03-11 21:42:19 -0600
committerRossTheRoss <mstrapp@protonmail.com>2021-03-11 21:42:19 -0600
commit7eedf9dab94b97c075f24348d1e88cdca0399f0d (patch)
tree1bebb4694d79311760860a944dfd9361aed12647 /csci4131/hw4/strap012
parentAdd Content type (diff)
downloadhomework-7eedf9dab94b97c075f24348d1e88cdca0399f0d.tar
homework-7eedf9dab94b97c075f24348d1e88cdca0399f0d.tar.gz
homework-7eedf9dab94b97c075f24348d1e88cdca0399f0d.tar.bz2
homework-7eedf9dab94b97c075f24348d1e88cdca0399f0d.tar.lz
homework-7eedf9dab94b97c075f24348d1e88cdca0399f0d.tar.xz
homework-7eedf9dab94b97c075f24348d1e88cdca0399f0d.tar.zst
homework-7eedf9dab94b97c075f24348d1e88cdca0399f0d.zip
Finish hw4
Diffstat (limited to '')
-rw-r--r--csci4131/hw4/strap012/strap012.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/csci4131/hw4/strap012/strap012.py b/csci4131/hw4/strap012/strap012.py
index ec0ecc3..31668af 100644
--- a/csci4131/hw4/strap012/strap012.py
+++ b/csci4131/hw4/strap012/strap012.py
@@ -22,6 +22,7 @@ def check_perms(resource):
stmode = os.stat(resource).st_mode
return(getattr(stat, 'S_IROTH') & stmode) > 0
+# Puts together the HTML for the POST form return
def POST(form):
form = unquote(form)
form = form.replace("+", " ").split("&")
@@ -32,9 +33,9 @@ def POST(form):
x = x.split("=")
contents = contents + "<tr>\n<td>" + x[0] + "</td>\n<td>" + x[1] + "</td>\n</tr>\n"
table = "<table>" + contents + "</table>"
- ret = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset='utf-8'>\n<link rel='stylesheet' href='style.css'>\n<title>Test</title>\n</head>\n<body>\n<h2>\nFollowing Form Data Submitted Successfully:</h2><br>\n{}\n</body>\n</html>".format(table)
+ ret = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset='utf-8'>\n<link rel='stylesheet' href='style.css'>\n<title>Test</title>\n</head>\n<body>\n<h3>\nFollowing Form Data Submitted Successfully:</h3><br>\n{}\n</body>\n</html>".format(table)
return ret
-
+#For Content Type
def getType(type):
if type == "html":
return "text/html"
@@ -54,7 +55,7 @@ def getType(type):
def getContents(type, file, contents):
if type =="POST":
return b"".join(
- [OK.encode(), "{}".format(CRLF), POST(contents).encode(), "{}{}".format(CRLF, CRLF).encode()])
+ [OK.encode(), "{}".format(CRLF).encode(), POST(contents).encode(), "{}{}".format(CRLF, CRLF).encode()])
returnValue = "".encode()
try:
if file.split("?")[0] == "redirect":