flet-web 1.0.0.dev0__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/PKG-INFO +6 -2
  2. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/README.md +4 -0
  3. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/pyproject.toml +2 -2
  4. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/fastapi/flet_static_files.py +4 -1
  5. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/patch_index.py +21 -6
  6. flet_web-1.0.1/src/flet_web/version.py +1 -0
  7. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web.egg-info/PKG-INFO +6 -2
  8. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web.egg-info/SOURCES.txt +2 -1
  9. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web.egg-info/requires.txt +1 -1
  10. flet_web-1.0.1/tests/test_patch_index.py +34 -0
  11. flet_web-1.0.0.dev0/src/flet_web/version.py +0 -1
  12. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/setup.cfg +0 -0
  13. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/__init__.py +0 -0
  14. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/fastapi/__init__.py +0 -0
  15. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/fastapi/app.py +0 -0
  16. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/fastapi/flet_app.py +0 -0
  17. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/fastapi/flet_app_manager.py +0 -0
  18. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/fastapi/flet_fastapi.py +0 -0
  19. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/fastapi/flet_oauth.py +0 -0
  20. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/fastapi/flet_upload.py +0 -0
  21. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/fastapi/oauth_state.py +0 -0
  22. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/fastapi/serve_fastapi_web_app.py +0 -0
  23. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web/uploads.py +0 -0
  24. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web.egg-info/dependency_links.txt +0 -0
  25. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/src/flet_web.egg-info/top_level.txt +0 -0
  26. {flet_web-1.0.0.dev0 → flet_web-1.0.1}/tests/test_loading_logo.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flet-web
3
- Version: 1.0.0.dev0
3
+ Version: 1.0.1
4
4
  Summary: Flet web client in Flutter.
5
5
  Author-email: "Appveyor Systems Inc." <hello@flet.dev>
6
6
  License-Expression: Apache-2.0
@@ -9,7 +9,7 @@ Project-URL: Repository, https://github.com/flet-dev/flet
9
9
  Project-URL: Documentation, https://flet.dev/docs
10
10
  Requires-Python: >=3.10
11
11
  Description-Content-Type: text/markdown
12
- Requires-Dist: flet==1.0.0.dev0
12
+ Requires-Dist: flet==1.0.1
13
13
  Requires-Dist: fastapi>=0.115.12
14
14
  Requires-Dist: uvicorn[standard]>=0.35.0
15
15
 
@@ -19,3 +19,7 @@ Requires-Dist: uvicorn[standard]>=0.35.0
19
19
  [![docstring coverage](https://flet.dev/docs/assets/badges/docs-coverage/flet-web.svg)](https://flet.dev/docs/assets/badges/docs-coverage/flet-web.svg)
20
20
 
21
21
  This package contains a compiled Flutter Flet web client.
22
+
23
+ > **[Try Flet online in Flet Studio](https://studio.flet.dev)**
24
+ >
25
+ > Write, run, and share Flet web apps right in your browser. No local setup required. Write your own Python code or get help from the AI agent.
@@ -4,3 +4,7 @@
4
4
  [![docstring coverage](https://flet.dev/docs/assets/badges/docs-coverage/flet-web.svg)](https://flet.dev/docs/assets/badges/docs-coverage/flet-web.svg)
5
5
 
6
6
  This package contains a compiled Flutter Flet web client.
7
+
8
+ > **[Try Flet online in Flet Studio](https://studio.flet.dev)**
9
+ >
10
+ > Write, run, and share Flet web apps right in your browser. No local setup required. Write your own Python code or get help from the AI agent.
@@ -1,13 +1,13 @@
1
1
  [project]
2
2
  name = "flet-web"
3
- version = "1.0.0.dev0"
3
+ version = "1.0.1"
4
4
  description = "Flet web client in Flutter."
5
5
  authors = [{ name = "Appveyor Systems Inc.", email = "hello@flet.dev" }]
6
6
  license = "Apache-2.0"
7
7
  readme = "README.md"
8
8
  requires-python = ">=3.10"
9
9
  dependencies = [
10
- "flet==1.0.0.dev0",
10
+ "flet==1.0.1",
11
11
  "fastapi >=0.115.12",
12
12
  "uvicorn[standard] >=0.35.0"
13
13
  ]
@@ -177,7 +177,10 @@ class FletStaticFiles(StaticFiles):
177
177
 
178
178
  # "standard" web files
179
179
  web_dir = get_package_web_dir()
180
- logger.info(f"Web root: {web_dir}")
180
+ if os.getenv("FLET_WEB_PATH"):
181
+ logger.info(f"Web root set via FLET_WEB_PATH: {web_dir}")
182
+ else:
183
+ logger.info(f"Web root: {web_dir}")
181
184
 
182
185
  if not os.path.exists(web_dir):
183
186
  raise RuntimeError(f"Web root path not found: {web_dir}")
@@ -16,6 +16,7 @@ def patch_index_html(
16
16
  pyodide_pre: bool = False,
17
17
  pyodide_script_path: str = "",
18
18
  pyodide_version: Optional[str] = None,
19
+ app_package_url: Optional[str] = None,
19
20
  web_renderer: WebRenderer = WebRenderer.AUTO,
20
21
  route_url_strategy: RouteUrlStrategy = RouteUrlStrategy.PATH,
21
22
  no_cdn: bool = False,
@@ -33,9 +34,16 @@ def patch_index_html(
33
34
  websocket_endpoint_path: Optional websocket endpoint path.
34
35
  app_name: Optional app name used for page title and iOS web-app title meta.
35
36
  app_description: Optional app description meta content.
36
- pyodide: Whether to enable Pyodide mode in injected runtime config.
37
+ pyodide: Whether the page should run Python in the browser. Written to
38
+ the injected config either way, because a page carries whichever
39
+ mode it was generated for — `flet build web` bakes Pyodide in — and
40
+ serving that client from a Flet server has to turn it back off.
37
41
  pyodide_pre: Whether pre-release micropip packages are allowed.
38
42
  pyodide_script_path: Path to Python entry script for Pyodide apps.
43
+ app_package_url: URL of the archive holding the app's Python code,
44
+ relative to the page. Written to the injected config, because a
45
+ page names whichever archive it was generated for while a
46
+ publisher writes its own.
39
47
  web_renderer: Web renderer mode for the frontend runtime.
40
48
  route_url_strategy: URL strategy used by frontend routing.
41
49
  no_cdn: Whether CDN asset loading should be disabled.
@@ -49,18 +57,25 @@ def patch_index_html(
49
57
  base_url = base_href.strip("/").strip()
50
58
  base_url = "/" if base_url == "" else f"/{base_url}/"
51
59
 
52
- index = index.replace(
53
- '<base href="/">',
54
- f'<base href="{base_url}">',
60
+ index = re.sub(
61
+ r"(<base\b[^>]*\bhref\s*=\s*)([\"'])[^\"']*\2",
62
+ lambda match: f"{match[1]}{match[2]}{base_url}{match[2]}",
63
+ index,
64
+ count=1,
65
+ flags=re.IGNORECASE,
55
66
  )
56
67
 
57
68
  app_config = []
58
69
 
59
- if pyodide and pyodide_script_path:
70
+ run_in_browser = bool(pyodide and pyodide_script_path)
71
+ app_config.append(f"flet.pyodide = {str(run_in_browser).lower()};")
72
+
73
+ if run_in_browser:
60
74
  module_name = Path(pyodide_script_path).stem
61
- app_config.append("flet.pyodide = true;")
62
75
  app_config.append(f"flet.micropipIncludePre = {str(pyodide_pre).lower()};")
63
76
  app_config.append(f'flet.pythonModuleName = "{module_name}";')
77
+ if app_package_url:
78
+ app_config.append(f'flet.appPackageUrl = "{app_package_url}";')
64
79
 
65
80
  # Pin the Pyodide runtime URL for this build. The web client used to fall
66
81
  # back to a hardcoded CDN URL when not in no-cdn mode; with multi-version
@@ -0,0 +1 @@
1
+ version = "1.0.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flet-web
3
- Version: 1.0.0.dev0
3
+ Version: 1.0.1
4
4
  Summary: Flet web client in Flutter.
5
5
  Author-email: "Appveyor Systems Inc." <hello@flet.dev>
6
6
  License-Expression: Apache-2.0
@@ -9,7 +9,7 @@ Project-URL: Repository, https://github.com/flet-dev/flet
9
9
  Project-URL: Documentation, https://flet.dev/docs
10
10
  Requires-Python: >=3.10
11
11
  Description-Content-Type: text/markdown
12
- Requires-Dist: flet==1.0.0.dev0
12
+ Requires-Dist: flet==1.0.1
13
13
  Requires-Dist: fastapi>=0.115.12
14
14
  Requires-Dist: uvicorn[standard]>=0.35.0
15
15
 
@@ -19,3 +19,7 @@ Requires-Dist: uvicorn[standard]>=0.35.0
19
19
  [![docstring coverage](https://flet.dev/docs/assets/badges/docs-coverage/flet-web.svg)](https://flet.dev/docs/assets/badges/docs-coverage/flet-web.svg)
20
20
 
21
21
  This package contains a compiled Flutter Flet web client.
22
+
23
+ > **[Try Flet online in Flet Studio](https://studio.flet.dev)**
24
+ >
25
+ > Write, run, and share Flet web apps right in your browser. No local setup required. Write your own Python code or get help from the AI agent.
@@ -19,4 +19,5 @@ src/flet_web/fastapi/flet_static_files.py
19
19
  src/flet_web/fastapi/flet_upload.py
20
20
  src/flet_web/fastapi/oauth_state.py
21
21
  src/flet_web/fastapi/serve_fastapi_web_app.py
22
- tests/test_loading_logo.py
22
+ tests/test_loading_logo.py
23
+ tests/test_patch_index.py
@@ -1,3 +1,3 @@
1
- flet==1.0.0.dev0
1
+ flet==1.0.1
2
2
  fastapi>=0.115.12
3
3
  uvicorn[standard]>=0.35.0
@@ -0,0 +1,34 @@
1
+ from html.parser import HTMLParser
2
+ from urllib.parse import urljoin
3
+
4
+ import pytest
5
+
6
+ from flet_web.patch_index import patch_index_html
7
+
8
+
9
+ class BaseParser(HTMLParser):
10
+ def handle_starttag(self, tag, attrs):
11
+ if tag == "base":
12
+ self.href = dict(attrs)["href"]
13
+
14
+
15
+ @pytest.mark.parametrize(
16
+ "base_tag",
17
+ ['<base href="/">', '<base href="/deployed/">', "<base href='/deployed/'>"],
18
+ )
19
+ @pytest.mark.parametrize("mount_path", ["/", "/apps/demo/"])
20
+ def test_client_scripts_resolve_under_server_mount(tmp_path, base_tag, mount_path):
21
+ index = tmp_path / "index.html"
22
+ index.write_text(
23
+ f"<html><head>{base_tag}<!-- fletAppConfig --></head>"
24
+ '<body><script src="flutter_bootstrap.js"></script></body></html>',
25
+ encoding="utf-8",
26
+ )
27
+
28
+ patch_index_html(str(index), base_href=mount_path)
29
+
30
+ parser = BaseParser()
31
+ parser.feed(index.read_text(encoding="utf-8"))
32
+ assert urljoin(parser.href, "flutter_bootstrap.js") == (
33
+ mount_path + "flutter_bootstrap.js"
34
+ )
@@ -1 +0,0 @@
1
- version = "1.0.0.dev0"
File without changes