python - how do I set an app path to get the image I upload on flask?
问题描述
I am working on a flask project and having a hard time getting the image I uploaded.
appPath = os.path.join(os.path.curdir, 'app')
trnsourceRoot = os.path.join(appPath, 'static/trnsource')
this is in my index.py
websvr
+trnsvr
|
\--trn_db.py
+app
|
\--main
|
--index.py
\--static
|
--trnsource
I checked where does my file upload on
C:\mirae\facnroll_aws_210215\app\static\trnsource\F21021701\M21021700
but I am getting a 404 error when the image is loaded on the web.
how do I solve this? If need more information, please ask me further questions to clarify.
Thanks ahead.
解决方案
I found that actually the path when I upload the picture was misleading and I fixed it by running python on the right path.
in index.py
I had appPath = os.path.join(os.path.curdir, 'app')
and it set the current python directory as the appPath.
Originally
the python was executed on the path above.
On the visual code terminal, I had to do cd websvr
which is the subfolder.
I did python run.py
and it resolved the problem.
推荐阅读
- java - com.mysql.cj.jdbc.exceptions.MysqlDataTruncation:数据截断:日期值不正确:
- python - 使用 USDA Food API 按食品名称而不是 foodID 进行搜索
- c++ - *New Coder* 格式化和操作符
- excel - 格式化表格样式“”,接收变量未定义错误码
- c# - Visual Studio 2019 类图设计器工具箱为空
- sql - 在 SQL Server 2016 中将日期从 T 格式转换为 YYYYMMDD 格式
- swift - 如何在 SwiftUI 中将滚动视图添加到屏幕的特定部分?
- python - 我不知道 Flask 中的 SQLAlchemy 缺少哪些库
- javascript - 元素隐式具有“任何”类型,因为“字符串”类型的表达式不能用于索引类型 - Phaser
- vpn - 直接在C中而不是通过Swift中的packetFlow.readPackets读取tun FD时,如何处理tun FD数据包的前导4字节协议?