add cache

This commit is contained in:
joachimschmidt557 2019-08-23 19:06:58 +02:00
parent bd18a473d4
commit 5af754d685

View file

@ -28,8 +28,11 @@ when isMainModule:
texFile = workingDir / pad & ".tex"
pdfFile = workingDir / pad & ".pdf"
if fileExists(texFile) and readFile(texFile) == content and fileExists(pdfFile):
# Use file from cache
resp(Http200, readFile(pdfFile), contentType="application/pdf")
else:
writeFile(texFile, content)
let (output, exitCode) = execCmdEx(quoteShellCommand(["pdflatex", "-halt-on-error", texFile]))
if exitCode == 0:
resp(Http200, readFile(pdfFile), contentType="application/pdf")