小编Lum*_*umy的帖子

在流中断管

我有一个Django项目我正在研究我想要流式传输一些mp3文件的地方.

我有同样的问题: 使用django流式传输mp3文件,从带有<audio>的页面读取

让我解释一下:我想要使用Django 流式传输ogg,并<audio>在我的html页面中使用标签

我有一个网址domain.tld/song/show/X/,X我的歌的名字在哪里.我可以使用VLC(直接使用文件路径)进行流式传输,我可以在测试期间进行流式传输(我写下我收到的内容并使用VLC读取).

但是当我打开我的浏览器并加载我的主页domain.tld<\audio\>使用网址加载时domain.tld/song/show/1/,我得到一个破损的大管,好像我的客户关闭了连接.

我在其他帖子上看到,当他们将服务器投入生产时,一些问题得到了解决.所以我django.wgsi在djangoproject.com上将我的应用程序推送到服务器上,使用apache 等.

我正在使用Django 1.5版在Debian 7上运行python 2.7.3.我的代码:

宋/ views.py

def playAudioFile(request, pk):
    f = get_stream_song(pk)# return a pipe from pipes.Template
    l = f.read() # the file is an ogg get by pydub.com
    f.close()
    size_read = 550000
    sr = size_read
    while sr == size_read:
        print "rep"
        r = l[:size_read]
        l=l[size_read:]
        sr = len(r)
        yield r
    time.sleep(0.1) 

#url : ~/song/show/X/
#@login_required …
Run Code Online (Sandbox Code Playgroud)

python django stream

6
推荐指数
1
解决办法
1148
查看次数

Flask 不使用 curl 身份验证

我正在运行 Flask 应用程序,使用带有 mod_wsgi 的 apache,以及我自己的 ssl 证书(自签名),我还使用 Flask-HTTPAuth lib(https://flask-httpauth.readthedocs.org/en/latest/)我确实使用 BasicAuth

app.auth = HTTPBasicAuth()
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用 curl 测试 api,但我的 Flask 应用程序没有让我登录。

这是卷曲线

/usr/bin/curl -H 'Accept: application/json' -H 'Content-type: application/json' -u 'user:mypasswd' --cacert path_to/rootCA.crt --key path_to/backend.key --cert path_to/backend.crt -X POST -d '{}' -vvv https://my_url:443/api/1.0/code/create
Run Code Online (Sandbox Code Playgroud)

有来自服务器的答复

* Hostname was NOT found in DNS cache
*   Trying ** ...
* Connected to ** (**) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: path_to/rootCA.crt
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, …
Run Code Online (Sandbox Code Playgroud)

python authentication curl http-headers flask

4
推荐指数
1
解决办法
1766
查看次数

标签 统计

python ×2

authentication ×1

curl ×1

django ×1

flask ×1

http-headers ×1

stream ×1