flask to exe

use package pyinstaller with flaskwebgui

first, we have a normal flask project with venv.

1
2
3
4
5
6
7
8
9
10
11
12
.
├── app
│   ├── __init__.py
│   ├── routes.py
│   └── templates
├── requirements.txt
├── run.py
└── venv
├── Include
├── Lib
├── Scripts
└── pyvenv.cfg

in run.py

1
2
3
4
5
6
7
from app import app
from flaskwebgui import FlaskUI

ui = FlaskUI(app, width=500, height=500)
if __name__ == '__main__':
# app.run(debug=True)
ui.run()

then when you use python run.py you run the flask website in chrome app mode.

if you want an .exe file, use this command

pyinstaller -w -F –add-data “./app/templates;./app/templates” run.py