FastAPI Routing Issue in Hugging Face Spaces
Hello everyone,I’ve deployed a FastAPI application on Hugging Face Spaces. Everything seems to be running smoothly, and there are no errors in the logs. However, when I try to access my endpoints via a browser or tools like Postman, I’m getting a “404 error” or a “Cannot POST” error.Here’s a brief overview of my setup:I have a FastAPI route defined as@app.get("/check_request")and another one as@app.post("/recommend").My Dockerfile specifies the CMD asCMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"].When I try to access the endpointhttps://huggingface.co/spaces/DjPapzin/Emo_Play/check_requestin my browser, I get a “404 error”. Similarly, when I use Postman to send a POST request tohttps://huggingface.co/spaces/DjPapzin/Emo_Play/recommend, I receive a “Cannot POST” error.Has anyone encountered a similar issue or have any insights on what might be going wrong? Any help or guidance would be greatly appreciated!
2023-09-14T15:41:16Z
DjPapzin:https://huggingface.co/spaces/DjPapzin/Emo_Play/check_requestHi@DjPapzin, use this URL as the root:https://djpapzin-emo-play.hf.space/All spaces are hosted on a separate subdomain and the Hub UI just displays that subdomain in an iframe. I think we block all programmatic requests that aren’t to the subdomain.
2023-09-15T06:01:20Z
Hi@freddyaboultonThank you so much for pointing that out! I was indeed trying to access the endpoints through the Hub UI, and your clarification about the separate subdomain makes perfect sense. I’ve now tried using the provided root URL, and it works as expected.Your assistance has been invaluable, and I genuinely appreciate the time you took to help. It’s gestures like these that make the community such a great place for developers.