simplify serveFile

This commit is contained in:
randomuser 2021-07-20 02:10:17 -05:00
parent b690b8f571
commit 5cb3a8c460
1 changed files with 8 additions and 9 deletions

15
esgd.py
View File

@ -3,7 +3,7 @@ import subprocess
import os
host = "localhost"
port = 70
port = 71
class GopherError(BaseException): pass
class RequestError(GopherError): pass
@ -130,15 +130,14 @@ def gopherRenderer(fileArray):
def serveFile(file, query, gph, context):
if fileCGI(file):
if not gph:
sendFileArray(cgi(file, query, context), context)
else:
sendFileArray(gopherRenderer(cgi(file, query, context)), context)
fa = cgi(file, query, context)
elif fileSendable(file):
if not gph: sendFile(file, context)
fa = [i.rstrip() for i in open(file).readlines()]
else:
sendFileArray(gopherRenderer([i.rstrip() for i in open(file).readlines()]), context)
else: notFound(context)
notFound(context)
return
if gph: fa = gopherRenderer(fa)
sendFileArray(fa, context)
class gopherHandler(socketserver.BaseRequestHandler):
def handle(self):