Make Cross Platform Desktop Apps with Flask
CREATE YOUR FIRST CROSS PLATFORM DESKTOP APP IN UNDER 15 MINUTES [PYTHON OR HTML]
In today's times, most websites have a standalone application. There are many ways to create desktop apps, C++, Electron, etc.
However, this tutorial is for all of you python lovers.
Prior Knowledge Required -
This tutorial uses Flask. If you don't know flask, don't worry! This tutorial can easily be understood to handle HTML files too!
Packages required -
Make sure you download these PyPi
shudder packages before hand -
pip3 install PyQTWebEngine
pip3 install flask
pip3 install pyinstaller
This is best done locally, as pyinstaller automatically detects OS. If you run on replit, it will build for Ubuntu.
Use this python code in your main.py -
Now when you run this, a window with your flask content comes!
Bundle with PyInstaller
Again, recommended to do this locally.
Open up your Command Prompt, Terminal, etc. And
cd into your apps directory.
App Directory -
Powershell, cmd, etc. Command to use -
Note: If your path has spaces, put it in quotes
cd into your directory, run this command -
Use these flags to enhance your app - (Put them between
APP NAME and
|Flag||What it does|
|Console Project only|
|Window Project only|
|If your project has other files such as a |
ADD DATA EXAPMLE
;for windows and
:for Unix (mac, linux)
LINUX AND MAC
Now, you should see a folder called dist. Open it- there should be one folder, named
YOUR APP NAME. Open that. Finally launch the exe, and voila! You can use this to generate an installer for your app.