摘要:我有一个html页面,在本地看起来很好,但是当我将它部署到heroku时,缺少一个背景图像。
我尝试过的:,我目前正在使用属性background-image: url(bg.jpg);
我也尝试过image-url(bg.jpg)和asset-url(bg.jpg) (这两种方法都不是本地的)。
我所读到的:从我所读到的有几种可能性
config.assets.compile = true
config.serve_static_assets = true 我真的不知道怎么设置这些?我一直看到"production.rb文件“引用,但我不知道这是什么?我可以在heroku仪表板中设置这些属性吗?
目前,我只需将代码推送到GitHub并从那里进行部署。我是Heroku的新手,一般的部署,任何关于这个主题的帮助都将不胜感激。
procfile
web: gunicorn app:appfile-structure
procfile
requirements.txt
app.py
templates
|- index.html
|- positive.html
|- negative.html
|- bg.jpg发布于 2020-05-06 14:20:11
我已经解决了这个问题。我现在意识到,因为这是一个酒瓶应用程序,它需要处理不同的。
以下更改将纠正错误:更改文件结构,将图像放入静态文件夹(Flask知道查找此信息),然后更改url调用。
file-structure
procfile
requirements.txt
app.py
static
|- img
|- bg.jpg
templates
|- index.html
|- positive.html
|- negative.html
|- bg.jpg和
background-image: url('/static/img/bg.jpg');我不知道为什么这解决了问题,但它是有效的!
https://stackoverflow.com/questions/61627497
复制相似问题