from fastapi import FastAPI
from pydantic import BaseModel
from stop_service import stop_server

app = FastAPI(title="RunComfy Stop Service")

class StopRequest(BaseModel):
    server_id: str

class StopResponse(BaseModel):
    server_id: str
    status: str
    message: str

@app.post("/stop", response_model=StopResponse)
async def stop_endpoint(request: StopRequest):
    result = stop_server(request.server_id)
    return result

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)
