글꼴을 멋지게로드하는 간단한 HTTP 서버를 얻으려고하고 있지만 제대로 작동 할 수는 있지만 작은 사각형 만받습니다.python 간단한 HTTP 서버 글꼴을로드하지 않는 멋진 글꼴
나는 그것이 일종의 MIME 형식 문제일지도 모른다라고 생각한다. HTML 페이지와 font-awesome 글꼴은 페이지가 브라우저에서 직접 열리거나 단순 HTTP 서버에서로드 할 때로드되지 않는 경우로드됩니다.
이 질문에
은 동일하지만 나에게 도움이되지 않았다 HTML 코드에<meta charset="UTF-8">
을 배치 보였다.
<html>
<head>
<meta charset="UTF-8">
<title>HW Test</title>
<!-- Bootstrap -->
<link href = "css/bootstrap.min.css" rel="stylesheet"></link>
<link href = "css/custom.css" rel="stylesheet"></link>
<link href = "css/font-awesome.min.css" rel="stylesheet"></link>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class = "container">
<div class="row">
<input id="box1" type="checkbox" />
<label for="box1">Checkbox 1</label>
<input id="box2" type="checkbox" />
<label for="box2">Checkbox 2</label>
</div>
...
체크 박스는 작은 사각형 박스를 확인하지 같습니다 Font awesome not loading when using Python simple http server
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from os import curdir, sep
import cgi
import subprocess as sub
import time
PORT_NUMBER = 8080
class myHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path=="/":
self.path="/index.html"
try:
sendReply = False
if self.path.endswith(".html"):
mimetype='text/html'
sendReply = True
if self.path.endswith(".jpg"):
mimetype='image/jpg'
sendReply = True
if self.path.endswith(".png"):
mimetype='image/png'
sendReply = True
if self.path.endswith(".gif"):
mimetype='image/gif'
sendReply = True
if self.path.endswith(".svg"):
mimetype='image/svg+xml'
sendReply = True
if self.path.endswith(".css"):
mimetype='text/css'
sendReply = True
if self.path.endswith(".js"):
mimetype='application/javascript'
sendReply = True
if self.path.endswith(".ttf"):
mimetype='application/x-font-ttf'
sendReply = True
if self.path.endswith(".otf"):
mimetype='application/x-font-opentype'
sendReply = True
if self.path.endswith(".woff"):
mimetype='application/font-woff'
sendReply = True
if sendReply == True:
#Open the static file requested and send it
f = open(curdir + sep + self.path, 'rb')
self.send_response(200)
self.send_header('Content-type',mimetype)
self.end_headers()
self.wfile.write(f.read())
f.close()
print(curdir + sep + self.path)
return
except IOError:
self.send_error(404,'File Not Found: %s' % self.path)
def do_POST(self):
if self.path=="/run":
form = cgi.FieldStorage(
fp=self.rfile,
headers=self.headers,
environ={'REQUEST_METHOD':'POST',
'CONTENT_TYPE':self.headers['Content-Type'],
})
#self.send_response(200)
#self.end_headers()
return
이 HTML 페이지의 일부입니다. 글꼴로 표시해야합니다. 멋지지 않습니다.
예, 그게 전부입니다. 고맙습니다! – Tobbe