Corin1998 commited on
Commit
ba67af2
·
verified ·
1 Parent(s): a996e11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import json
3
  import gradio as gr
4
  from typing import List, Tuple
 
5
 
6
  # グローバル最小依存で起動 → 実処理は遅延 import
7
  def _lazy_imports_for_main():
@@ -105,6 +106,12 @@ with gr.Blocks(title="営業自動化 Agent Studio", theme=gr.themes.Soft()) as
105
  outputs=[score_json, contexts_text, proposal_md, docx_file, pptx_file, next_actions, index_report],
106
  )
107
 
108
- # Spaces app.py `demo` を自動起動
 
 
 
 
 
109
  if __name__ == "__main__":
110
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
 
2
  import json
3
  import gradio as gr
4
  from typing import List, Tuple
5
+ from fastapi import FastAPI # ★ 追加
6
 
7
  # グローバル最小依存で起動 → 実処理は遅延 import
8
  def _lazy_imports_for_main():
 
106
  outputs=[score_json, contexts_text, proposal_md, docx_file, pptx_file, next_actions, index_report],
107
  )
108
 
109
+ # ====== ここが重要:FastAPI に Gradio をマウントして ASGI 変数 app を公開 ======
110
+ app = FastAPI()
111
+ # キューを使う場合は .queue() をマウント
112
+ app = gr.mount_gradio_app(app, demo.queue(), path="/")
113
+
114
+ # ローカル起動用のおまけ(Spaces では uvicorn app:app が使われる)
115
  if __name__ == "__main__":
116
+ import uvicorn
117
+ uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", "7860")))