by: vmanel, 8 years ago

Last edited: 8 years ago

I have a Python Flask application that will display the live streaming of the raspberry pi camera on the browser, when I directly run the program it is working fine but when I deploy it in apache2 server, only text is getting displayed, but not the image.This is the main program that will generate frames
<pre class='prettyprint lang-py'>
#!/usr/bin/env python
from flask import Flask, render_template, Response

# Raspberry Pi camera module (requires picamera package)
from camera_pi import Camera

app = Flask(__name__)


@app.route('/')
def index():
   """Video streaming home page."""
    return render_template('index.html')


def gen(camera):
    """Video streaming generator function."""
    while True:
        frame = camera.get_frame()
        yield (b'--framern'
               b'Content-Type: image/jpegrnrn' + frame + b'rn')


@app.route('/video_feed')
def video_feed():
    """Video streaming route. Put this in the src attribute of an img     tag."""
    return Response(gen(Camera()),
                  mimetype='multipart/x-mixed-replace; boundary=frame')


if __name__ == '__main__':
  app.run()
</pre>

This is the content of index.html

<pre class='prettyprint lang-py'>
<html>
  <head>
    <title>Video Streaming Demonstration</title>
  </head>
  <body>
    <h1>Video Streaming Demonstration</h1>
    <img src="{{ url_for('video_feed') }}" >
  </body>
</html>
</pre>

Here only content of h1 tag is getting displayed in the browser This is my conf file
<pre class='prettyprint lang-py'>
<VirtualHost *:80>
        ServerName myipaddress
        ServerAdmin youemail@email.com
        WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
        <Directory /var/www/FlaskApp/FlaskApp/>
                Order allow,deny
                Allow from all
        </Directory>
        Alias /static /var/www/FlaskApp/FlaskApp/static
        <Directory /var/www/FlaskApp/FlaskApp/static/>
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
</pre>

my ip address refers to 192.168..... I don't know how to work with apache server should I modify something in apache2.conf file?



You must be logged in to post. Please login or register an account.



??

-vmanel 8 years ago

You must be logged in to post. Please login or register an account.