Site icon George的生活點滴

Flet build App

寫完程式後,得利用 flet build 的命令來完成編譯,將程式碼打包成各平台所能執行的檔案,在 windows 環境下執行 flet build 和寫程式前,你應該先安裝 3 個程式:

撰寫程式

請先執行 flet create 來建立相關的程式

> flet create HelloWorld
Done!<
Run the app:
flet run HelloWorld   #之後要執行此程式,只要在現在的路徑下執行此命令即可

此命令產生出的目錄及檔案:

編輯完檔案後,可執行 flet run HelloWorld 看到結果,沒問題後就能開始編程式了

編譯程式

flet build apk   # 編譯成 Android 的 apk
# 執行後 apk 檔會放在該路徑下的 build/apk 的目錄下

若想編譯成 web 的程式,將 apk 改成 web即可

flet build web # 編譯成 Web 的 app

想要直接試 run 一下程式只需在產生的 web 目錄下,執行 python -m http.server 8080,在browser 上打上 http://127.0.0.1:8080 就能看到結果


=== English Version ===

After writing the program, you must use the flet build command to complete the compilation and package the program code into files that can be run on any platform. Before running flet build and writing the program in the Windows environment, you should install 3 programs:

Writing a Program

Please run flet create first to create the appropriate file and folder.

> flet create HelloWorld
Done!<
Run the app:
flet run HelloWorld   #之後要執行此程式,只要在現在的路徑下執行此命令即可

The folders and files generated by this command:

After editing the file, you can execute flet run HelloWorld to see the results. Once there are no problems, you can start programming.

Compiler

flet build apk   # Compile into Android apk
# The apk file under build/apk

If you want to compile it into a web program, just change apk to web

flet build web # Compile into Web app

If you want to run the program directly, just run python -m http.server 8080 in the generated web folder, type http://127.0.0.1:8080 in your browser and you will see the result.


Exit mobile version