日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python 简单web音频_Python Twisted web服务器音频fi

發布時間:2025/3/8 python 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 简单web音频_Python Twisted web服务器音频fi 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我嘗試用python中的twisted創建一個簡單的web服務器。不過,我無法提供m4a音頻文件。在

在當前程序中,當我加載http://localhost:8880/mp3.html時,它可以正常工作。它顯示音頻播放器和mp3播放。此外,程序同時打印“/mp3.html”和/測試.mp3". 在

但是,當我加載http://localhost:8880/m4a.html時,它不起作用。它顯示音頻播放器,但m4a無法播放。此外,該程序只打印“/m4a.html”,而不打印“/test.m4a”。在

我當前的代碼如下。在import urlparse

import os

from twisted.internet import reactor

from twisted.web.server import Site

from twisted.web.resource import Resource

from twisted.web.static import File

import time

import subprocess

import mimetypes

class playM4A(Resource):

isLeaf = True

def render_GET(self, request):

this=urlparse.urlparse(request.path)#scheme,netloc,path,query

root,ext=os.path.splitext(this.path)

filename=os.path.basename(request.path)

fileFolder=request.path.replace(filename,"")

self.serverRoot=os.getcwd()

print request.path

if ext==".m4a":

thisFile=File(self.serverRoot+request.path)

return File.render_GET(thisFile,request)

elif ext==".mp3":

thisFile=File(self.serverRoot+request.path)

return File.render_GET(thisFile,request)

elif filename=="m4a.html":

return """

Your browser does not support the audio element.

not m4a """

elif filename=="mp3.html":

return """

Your browser does not support the audio element.

not m4a """

resource = playM4A()

factory = Site(resource)

reactor.listenTCP(8880, factory)

reactor.run()

總結

以上是生活随笔為你收集整理的python 简单web音频_Python Twisted web服务器音频fi的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。