我在apachewebserver上的Raspberry Pi上托管了一个简单的Flask应用程序,使用来自https://blog.miguelgrinberg.com/post/video-streaming-with-flask的教程从PiCamera传输实时视频。我在本地一切正常,我可以访问我的http://localip:5000获取我的实时视频源。我现在想在生产服务器上托管它,我使用Apache。我设置了链接我的Flask应用程序的所有配置文件和目录结构,并将服务器设置为端口80。我访问http://ip:80,我的网页加载了一个标题,标题和静态文本,但下面的视频应该是一个“损坏的图像”的图片。检查浏览器上的webpage video元素后,服务器没有返回任何内容。在
我看到了另一个帖子Video Straming on raspberrypi using flask apche2and wsgi server,一个人遇到了和我一样的问题。他标记了一个答案,说Apache没有对picamera的根访问权限,因此无法访问它。我知道Apache以www数据组用户的身份运行,我不知道应该给哪个文件夹/文件以访问PiCamera。我不知道怎么从在这里。本地使用inbuildflask dev web服务器,一切都运行得很好,但是通过Apache提供服务时,摄像头无法捕捉图像。请帮帮我。以下是我的基本代码和配置(Flask应用程序名为VideoStream):
视频流.wsgi
#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/VideoStream/")
from VideoStream import app as application
Apache配置文件:
^{pr2}$目录结构:
/var/www/VideoStream/
VideoStream.wsgi
VideoStream/
__init__.py
camera_pi.py
base_camera.py
templates/index.html
烧瓶应用程序:
#!/usr/bin/python3
from importlib import import_module
import os
from flask import Flask, render_template, Response
from VideoStream.camera_pi import Camera
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
def gen(camera):
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@app.route('/video_feed')
def video_feed():
return Response(gen(Camera()),
mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run(host='10.0.0.69', threaded=True, debug=True)
目前没有回答
相关问题 更多 >
编程相关推荐