YoBatM commited on
Commit
3a9de65
·
verified ·
1 Parent(s): 833976d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -28,7 +28,7 @@ templates = Jinja2Templates(directory="templates")
28
  def img(request: Request):
29
  return Response(content=b64.b64decode(imags.img),media_type="image/jpeg") if imags.img else "No image"
30
  @app.get("/",response_class=HTMLResponse)
31
- def test(request: Request,q:str="ls",body:bool=True):
32
  with open("./v.tex","w") as k:
33
  k.write(format(q) if body else q)
34
  r=run("pdflatex v.tex".split(" "),capture_output=True)
@@ -36,7 +36,7 @@ def test(request: Request,q:str="ls",body:bool=True):
36
  return r.stderr
37
  else:
38
 
39
- images=convert_from_path("v.pdf",use_cropbox=True)
40
  images[0].save("v.jpg",format="JPEG")
41
  with open("v.jpg","rb") as t:
42
  v=b64.b64encode(t.read()).decode('UTF-8')
 
28
  def img(request: Request):
29
  return Response(content=b64.b64decode(imags.img),media_type="image/jpeg") if imags.img else "No image"
30
  @app.get("/",response_class=HTMLResponse)
31
+ def test(request: Request,q:str="ls",body:bool=True,x:int=1024,y:int=1024):
32
  with open("./v.tex","w") as k:
33
  k.write(format(q) if body else q)
34
  r=run("pdflatex v.tex".split(" "),capture_output=True)
 
36
  return r.stderr
37
  else:
38
 
39
+ images=convert_from_path("v.pdf",size=(x,y))
40
  images[0].save("v.jpg",format="JPEG")
41
  with open("v.jpg","rb") as t:
42
  v=b64.b64encode(t.read()).decode('UTF-8')