NicolasG2523 commited on
Commit
b7af6bf
Β·
verified Β·
1 Parent(s): 8e2338f

Upload gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +5 -7
gradio_app.py CHANGED
@@ -28,6 +28,7 @@ from fastapi.staticfiles import StaticFiles
28
  import uuid
29
 
30
  import base64
 
31
 
32
  from hy3dgen.shapegen.utils import logger
33
 
@@ -138,15 +139,12 @@ def build_model_viewer_html(save_folder, height=660, width=790, textured=False):
138
  template_html = template_html.replace('#height#', f'{height - offset}')
139
  template_html = template_html.replace('#width#', f'{width}')
140
  #template_html = template_html.replace('#src#', f'{related_path}/')
141
- template_html = template_html.replace('#src#', f'{mesh_file_path}/')
142
-
143
  f.write(template_html)
144
 
145
- print(related_path)
146
- print(mesh_file_path)
147
- print(output_html_path)
148
-
149
- iframe_tag = f'<iframe src="file=https://nicolasg2523-picsto3d.hf.space/gradio_api/file=/tmp{output_html_path}" height="{height}" width="100%" frameborder="0"></iframe>'
150
 
151
  print(f'Find html file {output_html_path}, {os.path.exists(output_html_path)}')
152
  print(iframe_tag)
 
28
  import uuid
29
 
30
  import base64
31
+ from html import escape
32
 
33
  from hy3dgen.shapegen.utils import logger
34
 
 
139
  template_html = template_html.replace('#height#', f'{height - offset}')
140
  template_html = template_html.replace('#width#', f'{width}')
141
  #template_html = template_html.replace('#src#', f'{related_path}/')
142
+ template_html = template_html.replace('#src#', f'{mesh_file_path}/')
 
143
  f.write(template_html)
144
 
145
+ tenplate_html_encoded = encode(tenplate_html)
146
+ iframe_tag = f'<iframe srcdoc="{tenplate_html_encoded}" height="{height}" width="100%" frameborder="0"></iframe>'
147
+ #iframe_tag = f'<iframe src="file=https://nicolasg2523-picsto3d.hf.space/gradio_api/file=/tmp{output_html_path}" height="{height}" width="100%" frameborder="0"></iframe>'
 
 
148
 
149
  print(f'Find html file {output_html_path}, {os.path.exists(output_html_path)}')
150
  print(iframe_tag)