Update app.py
Browse files
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):
|
| 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:
|
|
@@ -32,12 +32,13 @@ def test(request: Request,q:str="ls",body:bool=True):
|
|
| 32 |
if r.stderr:
|
| 33 |
return r.stderr
|
| 34 |
else:
|
| 35 |
-
global
|
|
|
|
| 36 |
images=convert_from_path("v.pdf")
|
| 37 |
images[0].save("v.jpg",format="JPEG")
|
| 38 |
with open("v.jpg","rb") as t:
|
| 39 |
v=b64.b64encode(t.read()).decode('UTF-8')
|
| 40 |
-
|
| 41 |
return templates.TemplateResponse("latex.html",
|
| 42 |
{
|
| 43 |
"q":q,
|
|
|
|
| 19 |
img_byte_arr = io.BytesIO()
|
| 20 |
image.save(img_byte_arr, format='JPEG')
|
| 21 |
return img_byte_arr.getvalue()
|
| 22 |
+
imags=[]
|
| 23 |
templates = Jinja2Templates(directory="templates")
|
| 24 |
@app.get("/image",response_class=Response)
|
| 25 |
def img(request: Request):
|
| 26 |
+
return Response(content=b64.b64decode(images[0]),media_type="image/jpeg") 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:
|
|
|
|
| 32 |
if r.stderr:
|
| 33 |
return r.stderr
|
| 34 |
else:
|
| 35 |
+
global imgs
|
| 36 |
+
|
| 37 |
images=convert_from_path("v.pdf")
|
| 38 |
images[0].save("v.jpg",format="JPEG")
|
| 39 |
with open("v.jpg","rb") as t:
|
| 40 |
v=b64.b64encode(t.read()).decode('UTF-8')
|
| 41 |
+
imgs=[v]
|
| 42 |
return templates.TemplateResponse("latex.html",
|
| 43 |
{
|
| 44 |
"q":q,
|