Running Flet Apps

Flet applications can be executed as desktop or web applications using the flet run command. This command initiates the app in a native OS window (desktop) or a web browser (web) with hot reload enabled for real-time updates.

Desktop App

To run a Flet app as a desktop application, use the flet run command. By default, it executes the main.py script in the current directory.

  • **Command:** flet run [script]
  • [script] can be a relative or absolute path to the Python script.
  • Web App

    To run a Flet app as a web application, use the --web (or -w) option.

  • **Command:** flet run --web [script]
  • A fixed port can be specified using --port (or -p) followed by the port number.
  • A new browser window/tab will open, using a random TCP port by default.
  • Watching for Changes

    By default, Flet watches the main script file for modifications and reloads the app upon saving. It does not watch other files by default.

  • **Options to modify watching behavior:**
  • * -d or --directory: Watch for changes only in the [script]'s directory. * -r or --recursive: Watch for changes recursively in the [script]'s directory and all sub-directories.

  • **Example:** flet run --recursive [script]