Skip to main content

Build Status

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:
# 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

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:
        <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

Original Author:

Name : Saurabh Wadekar
Email : saurabhwadekar420@gmail.com
County : 🇮🇳INDIA🇮🇳

Changes made by:

  • SmokyAce
  • Discrd: smokyace

Metadata

Release files for flet-route-static 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flet-route-static 0.0.2
File Size Uploaded
flet_route_static-0.0.2.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flet-route-static 0.0.2
File Interpreter ABI Platform
flet_route_static-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / flet_route_static-0.0.2.tar.gz

Download URL flet_route_static-0.0.2.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ceef32abbac3cfbf24c63d8efd8a5b086607573e068406a0ee48bea48d316297
BLAKE2b-256 checksum
How to use checksums
c5ce0f8cb393e5a328433bd4debe43960b59bdc6dc8122d81e71b824c3130767
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.4

Release files / flet_route_static-0.0.2-py3-none-any.whl

Download URL flet_route_static-0.0.2-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c1f64f6e120dd418359e16847568cc68a76d10be3ee20cc5557ecd598e58173
BLAKE2b-256 checksum
How to use checksums
02f1d43bfd89c507085681d2365c6baa6a574c5e250769f3d1137f2decaa8d8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page