simplify serveFile
This commit is contained in:
parent
b690b8f571
commit
5cb3a8c460
17
esgd.py
17
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)
|
||||
else:
|
||||
sendFileArray(gopherRenderer([i.rstrip() for i in open(file).readlines()]), context)
|
||||
else: notFound(context)
|
||||
fa = [i.rstrip() for i in open(file).readlines()]
|
||||
else:
|
||||
notFound(context)
|
||||
return
|
||||
if gph: fa = gopherRenderer(fa)
|
||||
sendFileArray(fa, context)
|
||||
|
||||
class gopherHandler(socketserver.BaseRequestHandler):
|
||||
def handle(self):
|
||||
|
|
Loading…
Reference in New Issue