flet-dev / flet-dev/flet

flet + fast_api always return http 200 OK or 302 even when path does not exist

Open
#2,796 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
17k
Forks
694
Avg merge
1d 14h
Merged PRs (30d)
33

Description

Hi,

I'm experiencing the following issue with flet, flet-fastapi and uvicorn. The application always returns http 200 ok response when I would expect a 404 response I used following example app:

import flet as ft
import flet_fastapi


async def root_main(page: ft.Page):
    await page.add_async(ft.Text("This is root app!"))


async def sub_main(page: ft.Page):
    await page.add_async(ft.Text("This is sub app!"))


app = flet_fastapi.FastAPI()


app.mount("/sub-app", flet_fastapi.app(sub_main))
app.mount("/", flet_fastapi.app(root_main))

When browsing to something like http:\localhost\invalidurl I still get http response 200. How can I get HTTP response 404?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the response behavior with the example using flet_fastapi.FastAPI, the two app.mount calls, and Uvicorn, including an invalid path. Trace how the mounted root and sub-app routes handle unmatched paths; done means invalid URLs return HTTP 404 instead of 200 or 302 without breaking the valid routes.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, backend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.