simikkk commited on
Commit
edfd6e5
·
verified ·
1 Parent(s): a08e410

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -13,6 +13,7 @@ import sqlite3
13
  import hashlib
14
  import secrets
15
  import random
 
16
  from datetime import datetime, timedelta
17
  from pathlib import Path
18
  from typing import Optional, List, Dict, Any
@@ -32,7 +33,6 @@ except ImportError:
32
  # image processing
33
  try:
34
  from PIL import Image
35
- import io
36
  IMAGE_OK = True
37
  except ImportError:
38
  IMAGE_OK = False
@@ -745,7 +745,7 @@ def get_frontend_html() -> str:
745
 
746
  <!-- Hidden Gradio Bridge Elements -->
747
  <div id="gradio-bridge" class="hidden-gradio">
748
- {gradio_bridge_html}
749
  </div>
750
 
751
  <script>
@@ -961,8 +961,11 @@ def get_gradio_bridge_html() -> str:
961
  def build_app():
962
  init_db()
963
 
964
- with gr.Blocks(css=CUSTOM_CSS, title="OmniParse AI") as app:
965
- gr.HTML(get_frontend_html().format(gradio_bridge_html=get_gradio_bridge_html()))
 
 
 
966
 
967
  # Hidden Gradio Elements for Bridge
968
  with gr.Row(visible=False):
@@ -1012,4 +1015,4 @@ def build_app():
1012
 
1013
  if __name__ == "__main__":
1014
  app = build_app()
1015
- app.launch(server_name="0.0.0.0", server_port=7860, show_error=True)
 
13
  import hashlib
14
  import secrets
15
  import random
16
+ import io
17
  from datetime import datetime, timedelta
18
  from pathlib import Path
19
  from typing import Optional, List, Dict, Any
 
33
  # image processing
34
  try:
35
  from PIL import Image
 
36
  IMAGE_OK = True
37
  except ImportError:
38
  IMAGE_OK = False
 
745
 
746
  <!-- Hidden Gradio Bridge Elements -->
747
  <div id="gradio-bridge" class="hidden-gradio">
748
+ __GRADIO_BRIDGE_HTML__
749
  </div>
750
 
751
  <script>
 
961
  def build_app():
962
  init_db()
963
 
964
+ # In Gradio 6.0, CSS is passed to launch()
965
+ with gr.Blocks(title="OmniParse AI") as app:
966
+ # Safely concatenate HTML to avoid str.format() errors with CSS braces
967
+ final_html = get_frontend_html().replace("__GRADIO_BRIDGE_HTML__", get_gradio_bridge_html())
968
+ gr.HTML(final_html)
969
 
970
  # Hidden Gradio Elements for Bridge
971
  with gr.Row(visible=False):
 
1015
 
1016
  if __name__ == "__main__":
1017
  app = build_app()
1018
+ app.launch(server_name="0.0.0.0", server_port=7860, show_error=True, css=CUSTOM_CSS)