WIP
This commit is contained in:
parent
f340da7e02
commit
582b7743f7
4 changed files with 39 additions and 23 deletions
24
src/etherpad2latex.nim
Normal file
24
src/etherpad2latex.nim
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import asynchttpserver, asyncdispatch
|
||||
import osproc, strutils, parseopt
|
||||
|
||||
proc getContent(pad:string):string =
|
||||
discard
|
||||
|
||||
proc requestHandler(req:Request) {.async.} =
|
||||
if req.url.path.startsWith("/compile"):
|
||||
let
|
||||
padName = req.url.path
|
||||
content = getContent(padName)
|
||||
let (output, exitCode) = execCmdEx("make")
|
||||
let headers = if exitCode == 0: newHttpHeaders([("Content-Type","application/pdf")])
|
||||
else: newHttpHeaders([("Content-Type","text/plain")])
|
||||
let pdf = if exitCode == 0: readFile("Abgabe.pdf")
|
||||
else: output
|
||||
await req.respond(Http200, pdf, headers)
|
||||
else:
|
||||
await req.respond(Http404, "Not a valid API call")
|
||||
|
||||
when isMainModule:
|
||||
var
|
||||
server = newAsyncHttpServer()
|
||||
waitFor server.serve(Port(8080), requestHandler)
|
||||
Loading…
Add table
Add a link
Reference in a new issue