lastwarning commited on
Commit
00cf9cd
·
verified ·
1 Parent(s): c413ef2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -533,7 +533,12 @@ def image_ui(prompt, model_name, seed, steps):
533
  # Gradio interface
534
  # ---------------------------------------------------------------------
535
 
536
- with gr.Blocks(title=APP_NAME) as demo:
 
 
 
 
 
537
  gr.Markdown(
538
  "# ⚡ Tasting AI Studio\n"
539
  "Image Generation + AI Coding + Developer API"
@@ -545,7 +550,6 @@ with gr.Blocks(title=APP_NAME) as demo:
545
  label="Your API Base URL",
546
  value=get_base_url(),
547
  interactive=False,
548
- buttons=["copy"],
549
  )
550
  gr.Markdown("### API Key Manager")
551
  gr.Markdown(
@@ -558,7 +562,6 @@ with gr.Blocks(title=APP_NAME) as demo:
558
  new_key_box = gr.Textbox(
559
  label="New API Key — copy and save it",
560
  interactive=False,
561
- buttons=["copy"],
562
  )
563
  key_dropdown = gr.Dropdown(
564
  label="Previously Generated API Keys",
@@ -566,9 +569,8 @@ with gr.Blocks(title=APP_NAME) as demo:
566
  interactive=True,
567
  )
568
  old_key_box = gr.Textbox(
569
- label="Selected API Key — copy icon available",
570
  interactive=False,
571
- buttons=["copy"],
572
  )
573
  with gr.Row():
574
  show_key_btn = gr.Button("Show Selected Key")
@@ -652,9 +654,14 @@ with gr.Blocks(title=APP_NAME) as demo:
652
 
653
 
654
  # FastAPI owns API routes; Gradio UI is mounted at the root path.
 
655
  app = gr.mount_gradio_app(api, demo, path="/")
656
 
657
-
658
  if __name__ == "__main__":
 
659
  import uvicorn
660
- uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", "7860")))
 
 
 
 
 
533
  # Gradio interface
534
  # ---------------------------------------------------------------------
535
 
536
+ _gradio_major = int(gr.__version__.split(".")[0])
537
+ _blocks_kwargs = {"title": APP_NAME}
538
+ if _gradio_major < 6:
539
+ _blocks_kwargs["theme"] = gr.themes.Soft()
540
+
541
+ with gr.Blocks(**_blocks_kwargs) as demo:
542
  gr.Markdown(
543
  "# ⚡ Tasting AI Studio\n"
544
  "Image Generation + AI Coding + Developer API"
 
550
  label="Your API Base URL",
551
  value=get_base_url(),
552
  interactive=False,
 
553
  )
554
  gr.Markdown("### API Key Manager")
555
  gr.Markdown(
 
562
  new_key_box = gr.Textbox(
563
  label="New API Key — copy and save it",
564
  interactive=False,
 
565
  )
566
  key_dropdown = gr.Dropdown(
567
  label="Previously Generated API Keys",
 
569
  interactive=True,
570
  )
571
  old_key_box = gr.Textbox(
572
+ label="Selected API Key",
573
  interactive=False,
 
574
  )
575
  with gr.Row():
576
  show_key_btn = gr.Button("Show Selected Key")
 
654
 
655
 
656
  # FastAPI owns API routes; Gradio UI is mounted at the root path.
657
+ # HF Spaces launches the server automatically — do NOT call uvicorn here.
658
  app = gr.mount_gradio_app(api, demo, path="/")
659
 
 
660
  if __name__ == "__main__":
661
+ # Local dev only — not executed inside HF Spaces.
662
  import uvicorn
663
+ port = int(os.getenv("PORT", "7860"))
664
+ _launch_kwargs = {}
665
+ if _gradio_major >= 6:
666
+ _launch_kwargs["theme"] = gr.themes.Soft()
667
+ uvicorn.run("app:app", host="0.0.0.0", port=port, reload=False)