Skip to content

Commit 29f2c19

Browse files
authored
Add proxy_path parameter to flet_fastapi.app() (#1882)
* hotfix to enable flet-fastapi apps configured at different locations * Using parameter name instead of * Fix * Fix newline * Fix newline
1 parent 029c2e2 commit 29f2c19

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

sdk/python/packages/flet-fastapi/src/flet_fastapi/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
def app(
1818
session_handler: Callable[[Page], Awaitable],
19+
proxy_path: Optional[str] = None,
1920
assets_dir: Optional[str] = None,
2021
app_name: Optional[str] = None,
2122
app_short_name: Optional[str] = None,
@@ -79,6 +80,7 @@ async def oauth_redirect_handler(request: Request):
7980
fastapi_app.mount(
8081
path="/",
8182
app=FletStaticFiles(
83+
proxy_path=proxy_path,
8284
assets_dir=assets_dir,
8385
app_name=app_name,
8486
app_short_name=app_short_name,

sdk/python/packages/flet-fastapi/src/flet_fastapi/flet_static_files.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class FletStaticFiles(StaticFiles):
3939

4040
def __init__(
4141
self,
42+
proxy_path: Optional[str] = None,
4243
assets_dir: Optional[str] = None,
4344
app_name: Optional[str] = None,
4445
app_short_name: Optional[str] = None,
@@ -50,6 +51,7 @@ def __init__(
5051
) -> None:
5152
self.index = "index.html"
5253
self.manifest_json = "manifest.json"
54+
self.__proxy_path = proxy_path
5355
self.__assets_dir = assets_dir
5456
self.__app_name = app_name
5557
self.__app_short_name = app_short_name
@@ -83,7 +85,10 @@ def lookup_path(self, path: str) -> Tuple[str, Optional[os.stat_result]]:
8385
return (full_path, stat_result)
8486

8587
async def __config(self, root_path: str):
86-
self.__app_mount_path = root_path
88+
if self.__proxy_path:
89+
self.__app_mount_path = self.__proxy_path + root_path
90+
else:
91+
self.__app_mount_path = root_path
8792

8893
# where modified index.html is stored
8994
temp_dir = tempfile.mkdtemp()

0 commit comments

Comments
 (0)