英文:
404 Error while using Flask web app in PyInstaller executable
问题
我有一个基于Flask的Web应用程序,当我从脚本python my_script.py --web运行它时,它运行良好。
然而,当我使用PyInstaller打包它并使用.\my_script.exe --web运行时,根据日志和网络端口的检查,一切似乎都正常工作。
但在浏览器中它显示"404 Not Found"。
英文:
I have a web application based on Flask, when I run it from the script python my_script.py --web, it works well.
However after I package it using PyInstaller with pyinstaller my_script.spec and run it with .\my_script.exe --web, everything seems to work fine according to the log and the web application is opened at a port (checked with netstat)
But in browser it gives "404 Not Found"
答案1
得分: 0
我解决了这个问题。应用程序需要我 frontend/dist 文件夹中的一部分代码。要运行 Flask 应用程序,我们必须将所需的代码复制到可执行文件的相同路径,即将 frontend 复制到 dist\my_script。
英文:
I solved the problem. The app requires some part of the code in my frontend/dist folder. To run Flask application, we have to copy the code needed to the same path of the executable, which is copy frontend to dist\my_script
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论