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