AnswerDotAI / AnswerDotAI/fasthtml
[BUG] Adding BackgroundTask to Redirect results in 200 response.
- Dominant language
- Jupyter Notebook
- Stars
- 7k
- Forks
- 319
- Avg merge
- 28m
- Merged PRs (30d)
- 3
Description
**Describe the bug**
Adding `BackgroundTask` to `Redirect` response results in 200 status code.
**Minimal Reproducible Example**
```python
app = FastHTML()
cli = TestClient(app, follow_redirects=False)
@app.get("/background")
def background_task():
def long_running_task():
time.sleep(0.1)
print("Background task completed!")
return Redirect("/"), BackgroundTask(long_running_task)
r = cli.get("/background")
print(r)
print(r.text)
```
Output:
```
Background task completed!
FastHTML page
...
```
**Expected behavior**
Expect response. with 303 status code
**Environment Information**
Please provide the following version information:
- fastlite version: 0.1.3
- fastcore version: 1.8.1
- fasthtml version: 0.12.5
**Confirmation**
Please confirm the following:
- [x] I have read the FAQ (https://docs.fastht.ml/explains/faq.html)
- [x] I have provided a minimal reproducible example
- [x] I have included the versions of fastlite, fastcore, and fasthtml
- [x] I understand that this is a volunteer open source project with no commercial support.
Contributor guide
Assessment
This issue has not been assessed yet.