CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-lona

Write responsive web apps in full python

Pending
Overview
Eval results
Files

static-files-assets.mddocs/

Static Files and Assets

Static file management system for CSS, JavaScript, images, and other assets with automatic URL generation, dependency ordering, and development/production optimization.

Capabilities

Static File Classes

Classes for managing different types of static assets.

class StaticFile:
    def __init__(self, name: str, path: str = '', string: str = ''):
        """
        Base static file descriptor.
        
        Args:
            name (str): File identifier name
            path (str): File system path
            string (str): File content as string
        """
    
    # Properties
    name: str                   # File identifier
    path: str                   # File system path
    url: str                    # Generated URL
    sort_order: int             # Loading order priority
    link: str                   # HTML link tag
    enabled_by_default: bool    # Default enabled state
    enabled: bool               # Current enabled state
    static_url_prefix: str      # URL prefix for static files

class StyleSheet(StaticFile):
    """CSS stylesheet file descriptor."""
    
class Script(StaticFile):
    """JavaScript file descriptor."""

Sort Order Constants

Constants for controlling static file loading order.

class SORT_ORDER:
    FRAMEWORK: int = 100        # Framework files (loaded first)
    LIBRARY: int = 200          # Library files (loaded second)
    APPLICATION: int = 300      # Application files (loaded last)

App Static File Methods

Methods for registering static files with the application.

# Available on App class
def add_static_file(self, name: str, string: str = '', path: str = ''):
    """
    Add static file to application.
    
    Args:
        name (str): File name/identifier
        string (str): File content as string
        path (str): Path to file on disk
    """

Usage Example

from lona import App
from lona.static_files import StyleSheet, Script, SORT_ORDER

app = App(__file__)

# Add CSS files
app.add_static_file('bootstrap.css', path='static/css/bootstrap.min.css')
app.add_static_file('main.css', path='static/css/main.css')

# Add JavaScript files
app.add_static_file('jquery.js', path='static/js/jquery.min.js')
app.add_static_file('app.js', path='static/js/app.js')

# Using static file objects
bootstrap_css = StyleSheet('bootstrap', path='static/bootstrap.min.css')
custom_js = Script('custom', string='console.log("Hello World");')

Types

from typing import Union, Optional

StaticFileName = str
StaticFilePath = str
StaticFileContent = str
SortOrderValue = int

Install with Tessl CLI

npx tessl i tessl/pypi-lona

docs

channel-communication.md

core-framework.md

events-interactivity.md

exception-handling.md

file-management.md

html-system.md

index.md

response-system.md

routing-urls.md

static-files-assets.md

tile.json