pythonflasklighttpdpipicamera

Use HTML interface to control a running python script on a lighttpd server


I am trying to find out what the best tool is for my project.

I have a lighttpd server running on a raspberry pi (RPi) and a Python3 module which controls the camera. I need a lot of custom control of the camera, and I need to be able to change modes on the fly.

I would like to have a python script continuously running which waits for commands from the lighttpd server which will ultimately come from a user interacting with an HTML based webpage through an intranet (no outside connections).

I have used Flask in the past to control a running script, and I have used FastCGI to execute scripts. I would like to continue using the lighttpd server over rather than switching entirely over to Flask, but I don't know how to interact with the script once it is actually running to execute individual functions. I can't separate them into multiple functions because only one script can control the camera at a time.

Is the right solution to set up a Flask app and have the lighttpd send requests there, or is there a better tool for this?


Solution

  • I have used Flask in the past to control a running script, and I have used FastCGI to execute scripts.

    Given your experience, one solution is to do what you know. lighttpd can execute your script via FastCGI. Python3 supports FastCGI with Flask (or other frameworks). A python3 app which serially processes requests will have one process issuing commands to the camera.

    I would like to continue using the lighttpd server over rather than switching entirely over to Flask, but I don't know how to interact with the script once it is actually running to execute individual functions.

    Configure your Flask app to run as a FastCGI app instead of as a standalone webserver.