simplify serveFile
This commit is contained in:
parent
b690b8f571
commit
5cb3a8c460
15
esgd.py
15
esgd.py
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue