Pythonanywhere,如何使用静态文件?网址是什么? [英] Pythonanywhere, how to use static files? url?
问题描述
我完全不了解 Pythonanywhere ,我不知道为什么静态文件没有加载...这里是我存储css和图像的路径,
ie static / images / wikiLang.png
等
/ static / admin / /usr/local/lib/python2.7/dist-packages/django/contrib/admin/media
/ static / / home / saadfast / WikiWorld / static
/ media / / home / saadfast / WikiWorld / media
客户端如何使用URL?
我在 search.html
中所做的一切:
< div id =TopheaderImg>
< img src =/ home / saadfast / WikiWorld / static / images / wikiLogo.pngwidth =100pxstyle =float:middle/>
< br />
< img src =/ home / saadfast / WikiWorld / images / wikipediaLang.pngwidth =100pxstyle =float:middle/>
< / div>
为什么图片没有加载?路径或URL应该是什么?
PythonAnywhere dev在这里:我认为问题出在你在HTML。映射
/ static / / home / saadfast / WikiWorld / static
pre>
表示在$ $ c $ / static / 的URL将在目录
/家/ saadfast / WikiWorld /静态
。所以这意味着你有< img src =/ home / saadfast / WikiWorld / static / images / wikiLogo。 pngwidth =100pxstyle =float:middle/>
您应该可以拥有
< img src =/ static / images / wikiLogo.pngwidth =100pxstyle =float:middle/>
I am completely new to Pythonanywhere, I cant figure out why static files are not loading... Here is the path where I stored css and images stuff, i.e.
static/images/wikiLang.png
etc/static/admin/ /usr/local/lib/python2.7/dist-packages/django/contrib/admin/media /static/ /home/saadfast/WikiWorld/static /media/ /home/saadfast/WikiWorld/media
where as in the client side how should I use the URL?
what i have done in the
search.html
:<div id="TopheaderImg"> <img src="/home/saadfast/WikiWorld/static/images/wikiLogo.png" width="100px" style="float:middle"/> <br /> <img src="/home/saadfast/WikiWorld/images/wikipediaLang.png" width="100px" style="float:middle"/> </div>
why the image is not loading? what should the path or URL?
解决方案PythonAnywhere dev here: I think the problem is in the paths you're using in your HTML. The mapping
/static/ /home/saadfast/WikiWorld/static
Means that URLs with
/static/
at the start will be looked for in the directory/home/saadfast/WikiWorld/static
. So that means that where you have<img src="/home/saadfast/WikiWorld/static/images/wikiLogo.png" width="100px" style="float:middle"/>
You should probably have
<img src="/static/images/wikiLogo.png" width="100px" style="float:middle"/>
这篇关于Pythonanywhere,如何使用静态文件?网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!