简体   繁体   English

无法让 Heroku 在 Flask 应用程序中检测到 json 文件

[英]Having trouble getting Heroku to detect a json file in a Flask app

Sorry if the question is too dumb.对不起,如果这个问题太愚蠢了。 Been trying to deploy a Flask app in Heroku but getting an error that says Heroku is not finding a json file I have in my root directory.一直试图在 Heroku 中部署一个 Flask 应用程序,但收到一条错误消息,指出 Heroku 没有找到我根目录中的 json 文件。 users_data_db.json This file has dummy user login data so i have it in a git ignore file. users_data_db.json这个文件有虚拟用户登录数据,所以我把它放在一个 git 忽略文件中。 I assume this is why Heroku may not be able to read the file?我想这就是为什么 Heroku 可能无法读取文件? What would be my alternative?我的选择是什么? I dont mind pulling out the file from the git ignore if i need to as the data is placeholder/fake passwords.我不介意从 git 中提取文件,如果我需要的话请忽略,因为数据是占位符/假密码。

The error logs after running heroku logs --tail are:运行heroku logs --tail后的错误日志是:

2020-08-20T00:10:11.527823+00:00 app[web.1]: File "/app/model.py", line 14, in load_user_db
2020-08-20T00:10:11.527824+00:00 app[web.1]: with open("users_data_db.json") as f:
2020-08-20T00:10:11.527824+00:00 app[web.1]: FileNotFoundError: [Errno 2] No such file or directory: 'users_data_db.json'
2020-08-20T00:10:11.528063+00:00 app[web.1]: [2020-08-20 00:10:11 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-08-20T00:10:11.672038+00:00 app[web.1]: [2020-08-20 00:10:11 +0000] [4] [INFO] Shutting down: Master
2020-08-20T00:10:11.672225+00:00 app[web.1]: [2020-08-20 00:10:11 +0000] [4] [INFO] Reason: Worker failed to boot.
2020-08-20T00:10:11.757052+00:00 heroku[web.1]: Process exited with status 3
2020-08-20T00:10:11.798465+00:00 heroku[web.1]: State changed from up to crashed

My root tree structure:我的根树结构:

- __pycache__
- .vscode
- static
- templates
- venv
- .gitignore
- app.py
- model.py
- notes_data_db.json
- Procfile
- README.md
- requirements.txt
- runtime.txt
- user.py
- users_data_db.json

my repo我的仓库

thanks!谢谢!

It might be because user_data_db.json does not exist in your repo?可能是因为user_data_db.json在你的 repo 中不存在?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM