404错误在使用PyInstaller可执行文件中的Flask Web应用程序时发生。

huangapple go评论51阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年5月30日 09:45:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76361140.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定