CoBeDigger commited on
Commit
edd5fd2
·
1 Parent(s): b11172c

fix: mount Gradio directly onto FastAPI to prevent HTTP 404 conflicts on evaluator routes

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -2
  2. app/main.py +11 -1
Dockerfile CHANGED
@@ -5,5 +5,4 @@ RUN pip install --no-cache-dir -r requirements.txt
5
  COPY . .
6
  EXPOSE 7860
7
  ENV PORT=7860
8
- # Start FastAPI on 8000 in background, then launch Gradio on 7860
9
- CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port 8000 & python gradio_app.py"]
 
5
  COPY . .
6
  EXPOSE 7860
7
  ENV PORT=7860
8
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
app/main.py CHANGED
@@ -127,6 +127,16 @@ async def api_health():
127
  except Exception as e:
128
  return ErrorResponse(error=str(e))
129
 
 
 
 
 
 
 
 
 
 
 
130
  def main():
131
  import uvicorn
132
- uvicorn.run("app.main:app", host="0.0.0.0", port=8000)
 
127
  except Exception as e:
128
  return ErrorResponse(error=str(e))
129
 
130
+ import gradio as gr
131
+ import urllib.request
132
+ import time
133
+
134
+ try:
135
+ from gradio_app import demo
136
+ app = gr.mount_gradio_app(app, demo, path="/")
137
+ except ImportError as e:
138
+ print(f"Warning: Could not import gradio dashboard: {e}")
139
+
140
  def main():
141
  import uvicorn
142
+ uvicorn.run("app.main:app", host="0.0.0.0", port=7860)