使用Python简单的http服务器时,字体真棒不加载 [英] Font awesome not loading when using Python simple http server
问题描述
我有这个简单的html文件,它使用字体真棒显示拇指向下图标。
I have this simple html file that displays the thumbs down icon using font awesome.
<html>
<script src="//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js"></script>
<script>
WebFont.load({
custom: {
families: ['FontAwesome'],
urls : ['//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css']
},
fontloading: function(familyName, fvd) {},
fontactive: function(familyName, fvd) {},
fontinactive: function(familyName, fvd) {
}});
</script>
<style type="text/css">
html{
background-color:black;
color:green;
}
.thumb_down:before {
content:"";
font-family: FontAwesome;
color: #ffffff;
}
</style>
<body>
<div class="thumb_down">I am here! </div>
</body>
</html>
工作小提琴这里
现在,当我尝试使用Python SimpleHTTPServer在本地机器上使用此功能时,我的字体无法正确呈现。我得到这个输出
Now when I try hosing this on my local machine using a Python SimpleHTTPServer, my font is not rendered properly. I get this output
python -m SimpleHTTPServer
但是,当我使用php服务器托管相同内容时,我会得到正确的结果,如小提琴中所示。
But when I host the same using a php server, I get the correct result as shown in the fiddle.
php -S localhost:9000
任何想法,如果这是一个python简单HTTP服务器的限制吗? p>
Any idea if this is a limitation of a python Simple HTTP Server?
推荐答案
这可能是编码。 PHP可能会添加一个头文件,而Python不是。如果你在< html>
标签之后添加这个标签(就像jsfiddle一样),它可能会工作
It's probably the encoding. PHP is probably adding a header and python is not. If you add this after your <html>
tag (like jsfiddle does) it will probably work
<head>
<meta charset="utf-8">
</head>
这篇关于使用Python简单的http服务器时,字体真棒不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!