在本地运行正常,但为什么上传到Google Run时出现Flask错误?

问题描述 投票:0回答:1

这是错误消息:

第一:

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1463, in wsgi_app
response = self.full_dispatch_request()

第二:

GET500921B1.1 sChrome 123 ``https://flask-selenium-app-qs6rhz6vcq-du.a.run.app/

我使用 Selenium 和 Flask 创建了一个动态网站抓取工具。在本地运行得很好,但是当我用 Docker 配置它并上传到 Google Run 时,出现了上面的错误。

当前的requirements.txt如下:不需要其他任何东西,因为它只是简单地抓取一页。

flask==3.0.2 beautifulsoup4==4.12.3 selenium==4.19.0 gunicorn==21.2.0 

配置容器时,Python版本为3.12。

我通过将端口设置为 8080 来更改它的工作方式。 我还运行了 wsgi.py ,如下所示。

if __name__ == "__main__":     app.run(port=8080)

Docker 也是如此。

CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8080", "wsgi:app"]     app.run(port=8080)

python selenium-webdriver flask
1个回答
0
投票

服务器 Linux 发行版无法运行 selenium,因为它们没有运行 chrome 的用户界面。您可以尝试在 Windows VDS 上或使用远程驱动程序进行设置。

而且我无法完全确定错误,因为您没有提供所有日志。

© www.soinside.com 2019 - 2024. All rights reserved.