我有一个表格,用户上传文件,其路径存储在数据库中,文件存储在'/static/uploads/images/'
。烧瓶没有提供图片
现在在我的模板时,我呼吁该图像显示我这样做:<img src="{{ asset_info.picture_location }}" />
的picture_location
是其中路径被保持的列。 asset_info
是模型对象。
由于某种原因,它在尝试检索图像时返回404: GET /static/uploads/images/motor.gif HTTP/1.1" 404 -
即使这是正确的路径,我可以在其中看到该文件。
检查破碎图像图标的网址页面上显示它从数据库中检索的正确路径:http://localhost:5000/static/uploads/images/motor.gif
在客户布劳尔的响应这样说:
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
我已经搜索了很多,但没有任何运气。是否有一个单独的方法,我应该调用/构建服务图像?
这个蓝图信息:assets_blueprint = Blueprint('assets', __name__, static_folder='/static', template_folder='templates')
目录是:
app/
assets/
views.py
asset_models.py
asset_forms.py
other_blueprints/
etc.py
static/
uploads/
images/
motor.gif
app.py
config.py
哪里是你statuc文件夹? – realli
@realli更新主目录的布局和静态文件夹信息。 – xGlorify
@realli其实我找出了问题,我只是不知道如何解决它。因为这一切都发生在资产蓝图和'/ assets /'sub-route'(@ assets_blueprint.route('/ assets/')之内,所以出于某种原因追加了/ assets/'在图像路径的前面,像这样; '/ assets/static/uploads/images/motor.gif' 但是它从数据库检索的路径只是: '/ static/uploads/images/motor.gif' –
xGlorify