0

I am working on a small project at home with a Raspberry Pi using Python to sense motion via a PIR and record a 30 second video when motion is detected - using a night vision camera. This part of the project is working and I decided to use Flask to create an endpoint server so that I could control the camera remotely (e.g. start sensing, end sensing, status page).

When the following app run configuration is used my application works - except the status page HTML is not updating on client side:

app.run(host='192.168.0.47', port=8000, debug=False)

My status endpoint route looks like this:

# status page api to return the log file in HTML format
@app.route('/status')
def status_return():
    # create the status page
    form_status_page()
    return render_template('index.html')

The form_status_page() function creates the index.html file and is updating the file on the server side.

Is there something I need add to force the update? After some interest searches I thought the solution was to change debug to True, but this causes the following error:

picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources
Kapi
  • 49
  • 5
  • What do you mean that the status page is not updating? There is nothing that would cause it to update - have you clicked `refresh` in your browser? – Mark Setchell Jul 10 '23 at 19:33
  • Is your recording app running in a loop and not letting `flask` run and respond to requests? – Mark Setchell Jul 10 '23 at 19:34
  • Thanks Mark. The render_update was being used incorrectly and I needed to add the variables to be set for the HTML file. The video recording is in a loop and was holding the thread - therefore not letting flask respond. Now fixed - simple design mistake in the end. – Kapi Jul 15 '23 at 12:13

0 Answers0