![Build Status](flet-route.png)
# This makes it easy to manage multiple views with dynamic routing.
This is an utility class based on repath library which allows matching ExpressJS-like routes and parsing their parameters, for example `/account/:account_id/orders/:order_id`.
## Differences from flet-route
- Flet-Route-Static is made to work with Flet Static Websites. The standard Flet-Route Package does not support this at the moment.
- Changes:
- Removed `repath` dependency.
- Removed `flet` dependency (Static websites install `flet-pyodide` by itself)
- Removed `CLI` commands (Does not need to be available in static websites)
### How To Use:
- Add `flet-easy-static` to your project `requirements.txt`
- How To Import Package:
```python
# Method 1: Importing the package as fs in your project
import flet_route_static as fs
# Method 2: Check if the platform is emscripten and import the package accordingly
# This method is useful if you want to run the same code on both the desktop and the web and you don't have to install flet_route_static package on your desktop
if sys.platform == "emscripten": # Check if in Pyodide environment
import flet_route_static as fs
else:
import flet_route as fs
```
- Now you can safely run `flet publish` on your static website application
### This pacakge is just a small modification of the original `Flet-Route` package and all the credit goes to the original author [Saurabh ](https://github.com/saurabhwadekar)
### How to make `--route-url-strategy path` work in flet-route-static:
- Since a static webpage with flet is a singe page application, the `--route-url-strategy path` does not work as expected when hosted (Not when running main.py)
- #### For Apache:
- Check if `Include conf/extra/httpd-vhosts.conf` is uncommented in `httpd.conf`
- Check if `LoadModule rewrite_module modules/mod_rewrite.so` is uncommented in `httpd.conf`
- Modify `httpd-vhosts.conf` to look like this:
```apacheconf
<VirtualHost *:80>
ServerAdmin webmaster@yourdomain.com
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
<Directory "C:/xampp/htdocs/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
RewriteEngine On
RewriteBase /
# Exclude phpmyadmin and acustom from rewrite rules
RewriteCond %{REQUEST_URI} ^/phpmyadmin [NC,OR]
RewriteCond %{REQUEST_URI} ^/!custom [NC]
RewriteRule ^ - [L]
# If a file or directory exists, serve it directly
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Otherwise, rewrite all other requests to index.html
RewriteRule ^ /index.html [L]
</Directory>
# Configuration for phpMyAdmin
Alias /phpmyadmin "C:/xampp/phpMyAdmin"
<Directory "C:/xampp/phpMyAdmin">
Options Indexes FollowSymLinks
AllowOverride All
<RequireAny>
# Localhost
Require ip 127.0.0.1
# IPv6 Localhost
Require ip ::1
# Specific IP
Require ip 192.168.10.161
</RequireAny>
</Directory>
# Configuration for acustom directory
Alias /!custom "C:/xampp/htdocs/!custom"
<Directory "C:/xampp/htdocs/!custom">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
# Configuration for phpMyAdmin
Alias /phpmyadmin "C:/xampp/phpMyAdmin"
<Directory "C:/xampp/phpMyAdmin">
Options Indexes FollowSymLinks
AllowOverride All
<RequireAny>
# Localhost
Require ip 127.0.0.1
# IPv6 Localhost
Require ip ::1
# Specific IP
Require ip 192.168.10.161
</RequireAny>
</Directory>
# Configuration for acustom directory
Alias /!custom "C:/xampp/htdocs/!custom"
<Directory "C:/xampp/htdocs/!custom">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
- This `httpd-vhosts.conf` file is for XAMPP. Modify it according to your server configuration
- `!custom` is a directory in `htdocs` which is not affected by the rewrite rules
- `htdocs` is the same directory where the `index.html` is located. In linux systems the directory is `/var/www/html` normally
- `phpmyadmin` is also not affected by the rewrite rules
- Everything else is redirected to `index.html` so that the SPA can handle the routing (Fixes so `website.com/route` works as expected)
- #### For Nginx:
- Work In Progress
## Installation
```
pip install flet-route-static
```
## Upgradation
```
pip install flet-route-static --upgrade
```
#### [📖 Read the documentation ](https://saurabhwadekar.github.io/flet-route-doc)
## Original Author:
<b>Name :</b> Saurabh Wadekar<br>
<b>Email :</b> saurabhwadekar420@gmail.com<br>
<b>County :</b> 🇮🇳INDIA🇮🇳<br>
### Changes made by:
- SmokyAce
- Discrd: smokyace
Raw data
{
"_id": null,
"home_page": "https://github.com/saurabhwadekar/flet_route",
"name": "flet-route-static",
"maintainer": "SmokyAce",
"docs_url": null,
"requires_python": null,
"maintainer_email": "smokyacetv@gmail.com",
"keywords": "flet, routing, flet_route_static, routes, flet app, flet-route, flet simple routing",
"author": "Saurabh Wadekar, SmokyAce",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/c5/ce/0f8cb393e5a328433bd4debe43960b59bdc6dc8122d81e71b824c3130767/flet_route_static-0.0.2.tar.gz",
"platform": null,
"description": "![Build Status](flet-route.png)\r\n# This makes it easy to manage multiple views with dynamic routing.\r\n\r\nThis is an utility class based on repath library which allows matching ExpressJS-like routes and parsing their parameters, for example `/account/:account_id/orders/:order_id`.\r\n\r\n## Differences from flet-route\r\n- Flet-Route-Static is made to work with Flet Static Websites. The standard Flet-Route Package does not support this at the moment.\r\n- Changes:\r\n - Removed `repath` dependency.\r\n - Removed `flet` dependency (Static websites install `flet-pyodide` by itself)\r\n - Removed `CLI` commands (Does not need to be available in static websites)\r\n### How To Use:\r\n- Add `flet-easy-static` to your project `requirements.txt`\r\n- How To Import Package:\r\n```python\r\n# Method 1: Importing the package as fs in your project \r\nimport flet_route_static as fs\r\n# Method 2: Check if the platform is emscripten and import the package accordingly\r\n# This method is useful if you want to run the same code on both the desktop and the web and you don't have to install flet_route_static package on your desktop\r\nif sys.platform == \"emscripten\": # Check if in Pyodide environment\r\n import flet_route_static as fs\r\nelse:\r\n import flet_route as fs\r\n ```\r\n- Now you can safely run `flet publish` on your static website application\r\n### This pacakge is just a small modification of the original `Flet-Route` package and all the credit goes to the original author [Saurabh ](https://github.com/saurabhwadekar) \r\n\r\n\r\n### How to make `--route-url-strategy path` work in flet-route-static:\r\n- Since a static webpage with flet is a singe page application, the `--route-url-strategy path` does not work as expected when hosted (Not when running main.py)\r\n - #### For Apache:\r\n - Check if `Include conf/extra/httpd-vhosts.conf` is uncommented in `httpd.conf`\r\n - Check if `LoadModule rewrite_module modules/mod_rewrite.so` is uncommented in `httpd.conf`\r\n - Modify `httpd-vhosts.conf` to look like this:\r\n ```apacheconf\r\n <VirtualHost *:80>\r\n ServerAdmin webmaster@yourdomain.com\r\n DocumentRoot \"C:/xampp/htdocs\"\r\n ServerName localhost\r\n \r\n <Directory \"C:/xampp/htdocs/\">\r\n Options Indexes FollowSymLinks Includes ExecCGI\r\n AllowOverride All\r\n Require all granted\r\n \r\n RewriteEngine On\r\n RewriteBase /\r\n \r\n # Exclude phpmyadmin and acustom from rewrite rules\r\n RewriteCond %{REQUEST_URI} ^/phpmyadmin [NC,OR]\r\n RewriteCond %{REQUEST_URI} ^/!custom [NC]\r\n RewriteRule ^ - [L]\r\n \r\n # If a file or directory exists, serve it directly\r\n RewriteCond %{REQUEST_FILENAME} -f [OR]\r\n RewriteCond %{REQUEST_FILENAME} -d\r\n RewriteRule ^ - [L]\r\n \r\n # Otherwise, rewrite all other requests to index.html\r\n RewriteRule ^ /index.html [L]\r\n </Directory>\r\n \r\n # Configuration for phpMyAdmin\r\n Alias /phpmyadmin \"C:/xampp/phpMyAdmin\"\r\n \r\n <Directory \"C:/xampp/phpMyAdmin\">\r\n Options Indexes FollowSymLinks\r\n AllowOverride All\r\n <RequireAny>\r\n # Localhost\r\n Require ip 127.0.0.1\r\n # IPv6 Localhost\r\n Require ip ::1\r\n # Specific IP\r\n Require ip 192.168.10.161 \r\n </RequireAny>\r\n </Directory>\r\n \r\n # Configuration for acustom directory\r\n Alias /!custom \"C:/xampp/htdocs/!custom\"\r\n \r\n <Directory \"C:/xampp/htdocs/!custom\">\r\n Options Indexes FollowSymLinks\r\n AllowOverride None\r\n Require all granted\r\n </Directory>\r\n </VirtualHost>\r\n \r\n # Configuration for phpMyAdmin\r\n Alias /phpmyadmin \"C:/xampp/phpMyAdmin\"\r\n \r\n <Directory \"C:/xampp/phpMyAdmin\">\r\n Options Indexes FollowSymLinks\r\n AllowOverride All\r\n <RequireAny>\r\n # Localhost\r\n Require ip 127.0.0.1\r\n # IPv6 Localhost\r\n Require ip ::1\r\n # Specific IP\r\n Require ip 192.168.10.161 \r\n </RequireAny>\r\n </Directory>\r\n \r\n # Configuration for acustom directory\r\n Alias /!custom \"C:/xampp/htdocs/!custom\"\r\n \r\n <Directory \"C:/xampp/htdocs/!custom\">\r\n Options Indexes FollowSymLinks\r\n AllowOverride None\r\n Require all granted\r\n </Directory>\r\n </VirtualHost>\r\n\r\n - This `httpd-vhosts.conf` file is for XAMPP. Modify it according to your server configuration\r\n - `!custom` is a directory in `htdocs` which is not affected by the rewrite rules\r\n - `htdocs` is the same directory where the `index.html` is located. In linux systems the directory is `/var/www/html` normally\r\n - `phpmyadmin` is also not affected by the rewrite rules\r\n - Everything else is redirected to `index.html` so that the SPA can handle the routing (Fixes so `website.com/route` works as expected)\r\n - #### For Nginx:\r\n - Work In Progress\r\n\r\n\r\n## Installation\r\n```\r\npip install flet-route-static\r\n```\r\n\r\n## Upgradation\r\n```\r\npip install flet-route-static --upgrade\r\n```\r\n\r\n\r\n#### [\u00f0\u0178\u201c\u2013 Read the documentation ](https://saurabhwadekar.github.io/flet-route-doc)\r\n\r\n\r\n## Original Author:\r\n\r\n<b>Name :</b> Saurabh Wadekar<br>\r\n<b>Email :</b> saurabhwadekar420@gmail.com<br>\r\n<b>County :</b> \u00f0\u0178\u2021\u00ae\u00f0\u0178\u2021\u00b3INDIA\u00f0\u0178\u2021\u00ae\u00f0\u0178\u2021\u00b3<br>\r\n\r\n### Changes made by: \r\n- SmokyAce\r\n- Discrd: smokyace\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "This makes it easy to manage multiple views with dynamic routing.",
"version": "0.0.2",
"project_urls": {
"Homepage": "https://github.com/saurabhwadekar/flet_route"
},
"split_keywords": [
"flet",
" routing",
" flet_route_static",
" routes",
" flet app",
" flet-route",
" flet simple routing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "02f1d43bfd89c507085681d2365c6baa6a574c5e250769f3d1137f2decaa8d8c",
"md5": "6658fbe2987c314838169cd84b859bc7",
"sha256": "7c1f64f6e120dd418359e16847568cc68a76d10be3ee20cc5557ecd598e58173"
},
"downloads": -1,
"filename": "flet_route_static-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6658fbe2987c314838169cd84b859bc7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7251,
"upload_time": "2024-05-19T14:05:43",
"upload_time_iso_8601": "2024-05-19T14:05:43.455764Z",
"url": "https://files.pythonhosted.org/packages/02/f1/d43bfd89c507085681d2365c6baa6a574c5e250769f3d1137f2decaa8d8c/flet_route_static-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c5ce0f8cb393e5a328433bd4debe43960b59bdc6dc8122d81e71b824c3130767",
"md5": "53f626616114a2cca079331bcd183d1f",
"sha256": "ceef32abbac3cfbf24c63d8efd8a5b086607573e068406a0ee48bea48d316297"
},
"downloads": -1,
"filename": "flet_route_static-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "53f626616114a2cca079331bcd183d1f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6344,
"upload_time": "2024-05-19T14:05:45",
"upload_time_iso_8601": "2024-05-19T14:05:45.603923Z",
"url": "https://files.pythonhosted.org/packages/c5/ce/0f8cb393e5a328433bd4debe43960b59bdc6dc8122d81e71b824c3130767/flet_route_static-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-19 14:05:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "saurabhwadekar",
"github_project": "flet_route",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "annotated-types",
"specs": [
[
"==",
"0.6.0"
]
]
},
{
"name": "anyio",
"specs": [
[
"==",
"3.7.0"
]
]
},
{
"name": "arrow",
"specs": [
[
"==",
"1.3.0"
]
]
},
{
"name": "backports.tarfile",
"specs": [
[
"==",
"1.1.1"
]
]
},
{
"name": "binaryornot",
"specs": [
[
"==",
"0.4.4"
]
]
},
{
"name": "build",
"specs": [
[
"==",
"0.10.0"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2023.5.7"
]
]
},
{
"name": "cffi",
"specs": [
[
"==",
"1.16.0"
]
]
},
{
"name": "chardet",
"specs": [
[
"==",
"5.2.0"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.3.2"
]
]
},
{
"name": "click",
"specs": [
[
"==",
"8.1.3"
]
]
},
{
"name": "cookiecutter",
"specs": [
[
"==",
"2.6.0"
]
]
},
{
"name": "cryptography",
"specs": [
[
"==",
"42.0.5"
]
]
},
{
"name": "dnspython",
"specs": [
[
"==",
"2.6.1"
]
]
},
{
"name": "docutils",
"specs": [
[
"==",
"0.21.2"
]
]
},
{
"name": "email_validator",
"specs": [
[
"==",
"2.1.1"
]
]
},
{
"name": "fastapi",
"specs": [
[
"==",
"0.111.0"
]
]
},
{
"name": "fastapi-cli",
"specs": [
[
"==",
"0.0.2"
]
]
},
{
"name": "flet",
"specs": [
[
"==",
"0.22.0"
]
]
},
{
"name": "flet-core",
"specs": [
[
"==",
"0.22.0"
]
]
},
{
"name": "flet-runtime",
"specs": [
[
"==",
"0.22.0"
]
]
},
{
"name": "h11",
"specs": [
[
"==",
"0.14.0"
]
]
},
{
"name": "httpcore",
"specs": [
[
"==",
"0.16.3"
]
]
},
{
"name": "httptools",
"specs": [
[
"==",
"0.6.1"
]
]
},
{
"name": "httpx",
"specs": [
[
"==",
"0.23.3"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.4"
]
]
},
{
"name": "importlib_metadata",
"specs": [
[
"==",
"7.1.0"
]
]
},
{
"name": "jaraco.classes",
"specs": [
[
"==",
"3.4.0"
]
]
},
{
"name": "jaraco.context",
"specs": [
[
"==",
"5.3.0"
]
]
},
{
"name": "jaraco.functools",
"specs": [
[
"==",
"4.0.1"
]
]
},
{
"name": "jeepney",
"specs": [
[
"==",
"0.8.0"
]
]
},
{
"name": "Jinja2",
"specs": [
[
"==",
"3.1.3"
]
]
},
{
"name": "keyring",
"specs": [
[
"==",
"25.2.0"
]
]
},
{
"name": "markdown-it-py",
"specs": [
[
"==",
"3.0.0"
]
]
},
{
"name": "MarkupSafe",
"specs": [
[
"==",
"2.1.5"
]
]
},
{
"name": "mdurl",
"specs": [
[
"==",
"0.1.2"
]
]
},
{
"name": "more-itertools",
"specs": [
[
"==",
"10.2.0"
]
]
},
{
"name": "nh3",
"specs": [
[
"==",
"0.2.17"
]
]
},
{
"name": "oauthlib",
"specs": [
[
"==",
"3.2.2"
]
]
},
{
"name": "orjson",
"specs": [
[
"==",
"3.10.2"
]
]
},
{
"name": "packaging",
"specs": [
[
"==",
"23.1"
]
]
},
{
"name": "pkginfo",
"specs": [
[
"==",
"1.10.0"
]
]
},
{
"name": "pycparser",
"specs": [
[
"==",
"2.22"
]
]
},
{
"name": "pydantic",
"specs": [
[
"==",
"2.7.1"
]
]
},
{
"name": "pydantic_core",
"specs": [
[
"==",
"2.18.2"
]
]
},
{
"name": "Pygments",
"specs": [
[
"==",
"2.17.2"
]
]
},
{
"name": "pypng",
"specs": [
[
"==",
"0.20220715.0"
]
]
},
{
"name": "pyproject_hooks",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
"==",
"2.9.0.post0"
]
]
},
{
"name": "python-dotenv",
"specs": [
[
"==",
"1.0.1"
]
]
},
{
"name": "python-multipart",
"specs": [
[
"==",
"0.0.9"
]
]
},
{
"name": "python-slugify",
"specs": [
[
"==",
"8.0.4"
]
]
},
{
"name": "PyYAML",
"specs": [
[
"==",
"6.0.1"
]
]
},
{
"name": "qrcode",
"specs": [
[
"==",
"7.4.2"
]
]
},
{
"name": "readme_renderer",
"specs": [
[
"==",
"43.0"
]
]
},
{
"name": "repath",
"specs": [
[
"==",
"0.9.0"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.31.0"
]
]
},
{
"name": "requests-toolbelt",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "rfc3986",
"specs": [
[
"==",
"1.5.0"
]
]
},
{
"name": "rich",
"specs": [
[
"==",
"13.7.1"
]
]
},
{
"name": "SecretStorage",
"specs": [
[
"==",
"3.3.3"
]
]
},
{
"name": "shellingham",
"specs": [
[
"==",
"1.5.4"
]
]
},
{
"name": "six",
"specs": [
[
"==",
"1.16.0"
]
]
},
{
"name": "sniffio",
"specs": [
[
"==",
"1.3.0"
]
]
},
{
"name": "starlette",
"specs": [
[
"==",
"0.37.2"
]
]
},
{
"name": "text-unidecode",
"specs": [
[
"==",
"1.3"
]
]
},
{
"name": "twine",
"specs": [
[
"==",
"5.0.0"
]
]
},
{
"name": "typer",
"specs": [
[
"==",
"0.12.3"
]
]
},
{
"name": "types-python-dateutil",
"specs": [
[
"==",
"2.9.0.20240316"
]
]
},
{
"name": "typing_extensions",
"specs": [
[
"==",
"4.11.0"
]
]
},
{
"name": "ujson",
"specs": [
[
"==",
"5.9.0"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.2.1"
]
]
},
{
"name": "uvicorn",
"specs": [
[
"==",
"0.29.0"
]
]
},
{
"name": "uvloop",
"specs": [
[
"==",
"0.19.0"
]
]
},
{
"name": "watchdog",
"specs": [
[
"==",
"4.0.0"
]
]
},
{
"name": "watchfiles",
"specs": [
[
"==",
"0.21.0"
]
]
},
{
"name": "websocket-client",
"specs": [
[
"==",
"1.5.3"
]
]
},
{
"name": "websockets",
"specs": [
[
"==",
"10.4"
]
]
},
{
"name": "zipp",
"specs": [
[
"==",
"3.18.1"
]
]
}
],
"lcname": "flet-route-static"
}