def execute(self, httpObject): filePath = self.rootDirectory + "/" + httpObject.getRequestPath() if not os.path.exists(filePath): httpObject.setField("Content-Type", "text/plain") return "File not found" params = httpObject.getParams().values() return str(subprocess.check_output(["python", filePath] + params))
def execute(self, httpObject): filePath = self.rootDirectory + "/" + httpObject.getRequestPath() if not os.path.exists(filePath): httpObject.setField("Content-Type", "text/plain") return "File not found" fileContent = "" with open(filePath, "rb") as file: byte = file.read(1) while byte != "": fileContent += byte byte = file.read(1) httpObject.setField("Content-Type", self.getFileContentType(filePath)) return fileContent
def canExecute(self, httpObject): return httpObject.getRequestPath() == "/upload/"
def canExecute(self, httpObject): return httpObject.getRequestPath() in "/register/"
def canExecute(self, httpObject): return re.match(".+\.py", httpObject.getRequestPath())
def canExecute(self, httpObject): return not (httpObject.getRequestPath() in ("", "/"))