# How BackgroundTasks FastAPI works in HuggingFace Space

**URL:** <https://discuss.huggingface.co/t/how-backgroundtasks-fastapi-works-in-huggingface-space/109597>\
**Category:** Spaces\
**Created:** [October 1, 2024, 10:34am UTC](https://discuss.huggingface.co/t/how-backgroundtasks-fastapi-works-in-huggingface-space/109597 "2024-10-01T10:34:59Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [October 2, 2024, 9:48am UTC](https://discuss.huggingface.co/t/how-backgroundtasks-fastapi-works-in-huggingface-space/109597/4 "2024-10-02T09:48:24Z")

</div>

Hello. Hmmm… I guess I was wrong.  
I thought HF’s Spaces port was **only 7860** available by default?  
Maybe the one that has to be set in the YAML part of the README.md.  
In your case, I don’t think the request is getting through to the Spaces program because even the error log isn’t changing.

@not-lain Do you know anything about that?

> **[Spaces Configuration Reference](https://huggingface.co/docs/hub/spaces-config-reference)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> [@FastAPI Routing Issue in Hugging Face Spaces](https://discuss.huggingface.co/t/fastapi-routing-issue-in-hugging-face-spaces/54962):
>
> 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 as CMD ["uvicorn", "app:app", "--hos…

---

_[View the full topic](https://discuss.huggingface.co/t/how-backgroundtasks-fastapi-works-in-huggingface-space/109597)._
