Python http.server实现简单的前端web服务器
import http.server
import socketserver
# 设置端口号和地址
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
Handler.extensions_map.update({
".js": "application/javascript",
".mjs": "application/javascript",
})
print(Handler.extensions_map)
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Serving on port {PORT}...")
httpd.serve_forever()
感谢扫码支持