Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ from fastapi.responses import JSONResponse
|
|
| 3 |
from hf_diffusion_service import HFDiffusionService
|
| 4 |
from PIL import Image
|
| 5 |
import io, base64
|
|
|
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
service = HFDiffusionService()
|
|
@@ -22,3 +23,9 @@ async def generate(file: UploadFile):
|
|
| 22 |
base64_img = base64.b64encode(buffer.getvalue()).decode("utf-8")
|
| 23 |
|
| 24 |
return JSONResponse(content={"image": f"data:image/png;base64,{base64_img}"})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from hf_diffusion_service import HFDiffusionService
|
| 4 |
from PIL import Image
|
| 5 |
import io, base64
|
| 6 |
+
import uvicorn
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
service = HFDiffusionService()
|
|
|
|
| 23 |
base64_img = base64.b64encode(buffer.getvalue()).decode("utf-8")
|
| 24 |
|
| 25 |
return JSONResponse(content={"image": f"data:image/png;base64,{base64_img}"})
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# ✅ Add this to start FastAPI server for Spaces
|
| 29 |
+
if __name__ == "__main__":
|
| 30 |
+
# Run uvicorn explicitly so Hugging Face sees a running server
|
| 31 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|