YoBatM commited on
Commit
dde7f29
·
verified ·
1 Parent(s): 4c850b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -19,11 +19,11 @@ def get_bytes_value(image):
19
  img_byte_arr = io.BytesIO()
20
  image.save(img_byte_arr, format='JPEG')
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:
@@ -36,8 +36,10 @@ def test(request: Request,q:str="ls",body:bool=True):
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
  })
 
19
  img_byte_arr = io.BytesIO()
20
  image.save(img_byte_arr, format='JPEG')
21
  return img_byte_arr.getvalue()
22
+ images=[]
23
  templates = Jinja2Templates(directory="templates")
24
  @app.get("/image",response_class=Response)
25
  def img(request: Request,encoded:str):
26
+ return b64.b64decode(images[0]) if len(images)>0 else "No image"
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:
 
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
+ images=[v]
40
  return templates.TemplateResponse("latex.html",
41
  {
42
+ "q":q,
43
  "request":request,
44
  "result":v
45
  })