GiantPandas commited on
Commit
4ea4acb
·
verified ·
1 Parent(s): a2311ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -33
app.py CHANGED
@@ -349,39 +349,6 @@ async def process_file(file_path):
349
  return str(tmp_file_path)
350
 
351
 
352
-
353
- import gradio as gr
354
- import base64, pathlib
355
-
356
-
357
-
358
- def embed_file(file, scale: float):
359
- """
360
- 将上传的文件转换为可嵌入 HTML:
361
- • PDF → 生成 blob:URL,用 <iframe> + #zoom=xx% 展示
362
- • 图片 → <img style="transform:scale()"> 并允许拖拽缩放
363
- """
364
- if file is None:
365
- return ""
366
-
367
- path = pathlib.Path(file.name)
368
- ext = path.suffix.lower()
369
- data = base64.b64encode(path.read_bytes()).decode()
370
-
371
- # ---------- 1. PDF ----------
372
- if ext == ".pdf":
373
-
374
-
375
- else:
376
- return (
377
- f'<div style="overflow:auto;border:1px solid #ccc;'
378
- f'width:100%;height:800px;text-align:center">'
379
- f'<img src="data:image/{ext[1:]};base64,{data}" '
380
- f'style="transform:scale({scale});transform-origin:0 0;" />'
381
- f'</div>'
382
- )
383
-
384
-
385
  if __name__ == '__main__':
386
  with gr.Blocks() as demo:
387
  with gr.Row():
 
349
  return str(tmp_file_path)
350
 
351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  if __name__ == '__main__':
353
  with gr.Blocks() as demo:
354
  with gr.Row():