YoBatM commited on
Commit
f4c2ee1
·
verified ·
1 Parent(s): ac61ce7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -21,6 +21,9 @@ def get_bytes_value(image):
21
  return img_byte_arr.getvalue()
22
 
23
  templates = Jinja2Templates(directory="templates")
 
 
 
24
  @app.get("/",response_class=HTMLResponse)
25
  def test(request: Request,q:str="ls",body:bool=True):
26
  with open("./v.tex","w") as k:
@@ -32,8 +35,9 @@ def test(request: Request,q:str="ls",body:bool=True):
32
  images=convert_from_path("v.pdf")
33
  images[0].save("v.jpg",format="JPEG")
34
  with open("v.jpg","rb") as t:
35
- v=f"data:image/jpeg;base64,{b64.b64encode(t.read())}"
36
  return templates.TemplateResponse("latex.html",
37
  {
38
  "request":request,
39
- "result":f'<img src="{v}"></img>'})
 
 
21
  return img_byte_arr.getvalue()
22
 
23
  templates = Jinja2Templates(directory="templates")
24
+ @app.get("/image",response_class=Response)
25
+ def img(request: Request,encoded:str):
26
+ return b64.b64decode(encoded)
27
  @app.get("/",response_class=HTMLResponse)
28
  def test(request: Request,q:str="ls",body:bool=True):
29
  with open("./v.tex","w") as k:
 
35
  images=convert_from_path("v.pdf")
36
  images[0].save("v.jpg",format="JPEG")
37
  with open("v.jpg","rb") as t:
38
+ v=b64.b64encode(t.read()).decode('UTF-8')
39
  return templates.TemplateResponse("latex.html",
40
  {
41
  "request":request,
42
+ "result":v
43
+ })