Spaces:
Sleeping
Sleeping
update (app): root shows docs
Browse files- Dockerfile +1 -1
- app.py → server_cancer_predictor.py +6 -0
Dockerfile
CHANGED
|
@@ -10,4 +10,4 @@ COPY --chown=user ./requirements.txt requirements.txt
|
|
| 10 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 11 |
|
| 12 |
COPY --chown=user . /app
|
| 13 |
-
CMD ["uvicorn", "
|
|
|
|
| 10 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 11 |
|
| 12 |
COPY --chown=user . /app
|
| 13 |
+
CMD ["uvicorn", "server_cancer_predictor:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py → server_cancer_predictor.py
RENAMED
|
@@ -20,6 +20,7 @@ Run this module to start the API server. Use the endpoints to train the model an
|
|
| 20 |
"""
|
| 21 |
|
| 22 |
from fastapi import FastAPI, HTTPException, BackgroundTasks
|
|
|
|
| 23 |
import uvicorn
|
| 24 |
|
| 25 |
# Import the CancerPredictor class
|
|
@@ -33,6 +34,11 @@ predictor = CancerPredictor()
|
|
| 33 |
# Global variable to store training status
|
| 34 |
training_status = "Not started"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def train_model(train_path: str, test_path: str):
|
| 37 |
global training_status
|
| 38 |
training_status = "In progress"
|
|
|
|
| 20 |
"""
|
| 21 |
|
| 22 |
from fastapi import FastAPI, HTTPException, BackgroundTasks
|
| 23 |
+
from fastapi.responses import RedirectResponse
|
| 24 |
import uvicorn
|
| 25 |
|
| 26 |
# Import the CancerPredictor class
|
|
|
|
| 34 |
# Global variable to store training status
|
| 35 |
training_status = "Not started"
|
| 36 |
|
| 37 |
+
# Redirect root to /docs
|
| 38 |
+
@app.get("/")
|
| 39 |
+
async def redirect_to_docs():
|
| 40 |
+
return RedirectResponse(url="/docs")
|
| 41 |
+
|
| 42 |
def train_model(train_path: str, test_path: str):
|
| 43 |
global training_status
|
| 44 |
training_status = "In progress"
|