【问题标题】:does python BaseHttpServer support Html5?python BaseHttpServer 支持 Html5 吗?
【发布时间】:2010-12-03 21:35:19
【问题描述】:

我正在使用 Python-2.6.6 的 BaseHttpServer。我无法让它与标签一起使用。 Python-2.6 真的支持 HTML5 吗?

这可能更有帮助:

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 283, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 309, in process_request
    self.finish_request(request, client_address)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 322, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 617, in __init__
    self.handle()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py", line 329, in handle
    self.handle_one_request()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py", line 323, in handle_one_request
    method()
  File "testServer.py", line 43, in do_GET
    self.send_error(404,'File Not Found: %s' % self.path)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py", line 357, in send_error
    self.send_response(code, message)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py", line 382, in send_response
    (self.protocol_version, code, message))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py", line 318, in write
    self.flush()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py", line 297, in flush
    self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 32] Broken pipe

服务器端:

if self.path.endswith(".ts"):           
    f = open("simpsons.ts", 'r')
    self.send_response(200)
    self.send_header('Content-type', 'video/mpegts')
    self.end_headers()      
    self.wfile.write(f.read())
    return

客户端:

video width='320' height='240' src="simpsons.ts" controls="controls" /video

图像代码(工作):

服务器端:

if self.path.endswith(".png"):          
    f = open("ps_logo2.png", 'r')
    self.send_response(200)
    self.send_header('Content-type', 'image/png')
    self.end_headers()      
    self.wfile.write(f.read())
    return 

客户端:

img src="ps_logo2.png" alt="No Image"/

【问题讨论】:

  • HTML5 与 HTTP 有什么关系?
  • 请定义“无法正常工作”
  • 我正在尝试在我的 html 中使用 Video 标签。使用视频标签 GET 请求,Python 给出:错误:[Errno 32] 服务器端管道损坏。与图像标签一样,它的工作非常好。
  • 贴一些代码让我们看看
  • 非常有趣的是,您从“破管”错误中推断出 HTML5 问题。 HTML5 与您的问题无关。

标签: python http html


【解决方案1】:

HTML5 支持主要存在于浏览器级别,而不是语言级别。所以是的,Python 确实隐式支持 HTML5。

【讨论】:

    【解决方案2】:

    您似乎误诊了您的问题。 HTML5 完全是浏览器端。破裂的管道表示其他东西。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-31
      • 1970-01-01
      • 2013-05-11
      • 1970-01-01
      • 1970-01-01
      • 2012-10-25
      • 2012-02-06
      • 1970-01-01
      相关资源
      最近更新 更多