I’m using React+Python for my web app, and using pyinstaller to build the app into a debian package.
I’m using this command in my build script:
pyinstaller --add-data "static:static" --onefile src/$app.py --name $app-$VERSION --log-level WARN --distpath $BUILD_DIR/$COMPONENTS_DIR/$app/pyinstaller/dist/ --workpath $BUILD_DIR/$COMPONENTS_DIR/$app/pyinstaller/temp/
I also added a path to the dist folder (that was generated by running npm run build), in my Flask code (in flask-app.py). I tried a few different ways:
app = Flask(__name__, static_url_path='', static_folder='server/static')
app = Flask(__name__, static_folder='server/static')
app = Flask(__name__, static_url_path='', static_folder='static')
app = Flask(__name__, static_folder='static')
app = Flask(__name__, static_url_path='', static_folder='../../client/dist')
I also copied the contents of the dist folder to a “static” folder in my server directory (because my pyinstaller command has –add-data “static:static”, and I didn’t know how to refer to the client/dist folder path from that command
My folder structure is:
-server (folder)
-static (folder)
-build.sh
-src (folder)
-flask-app.py
-client
-dist (folder)
It still doesn’t work (when I run the flask server or when I run the debian file, it doesn’t serve up the React server..)
Am I missing something? Is there any special config needed for pyinstaller to get the Flask app to serve the React files? Was it correct to copy the contents of React’s dist folder into “static”? Thanks so much for the help!