I would like to have one python script running in a loop on my RPi. Basically, this script will take some picture with the camera and try to do some face recognization. I also would like to have a website, that would act as a control panel for the script. In this control panel I will be able to suspend the face recognization, to see the logs(who has been seen), and check the unknown people, and configure them.

I know how to do my python script, I've some knowledge in HTML/CSS/JS/WebService, but I've no idea how:

  • To have an interaction between the script and the web application(like how to give a flag that would pause the script)
  • Host a website on a RPI
  • Have the script that could push some things to the website(through a websocket)

Is all that possible? How can I achieve this?

Thank you

  • Did you ever get implemented what you wanted? I also have a similar problem.
    – Nazar
    Mar 24, 2018 at 18:34
  • @Nazar, I did, but with Asp.Net Core 2 ;)
    – J4N
    Mar 26, 2018 at 10:58

1 Answer 1


I'd recommend trying Flask. It's a Python based framework that should let you put together your dashboard. As you'd only be working in one familiar language it shouldn't be too complicated to get your existing code to talk to the front end.

For example, the most basic of basic Flask programs (provided in their docs) which sets up a route and returns a string is:

from flask import Flask
app = Flask(__name__)

def hello_world():
    return 'Hello, World!'

Flask's quick start docs are a useful place to begin, and should have enough information to get you up and running with a basic site. I notice that they've updated their site since the last time I visited, and it now includes a useful-looking page of documentation on deployment options - at least one or two of the self-hosted options should be workable on a Pi.

  • Thank you for your answer. I see, but how can I interact between Flask and my python script?(I'm by far not a python expert, more a c# guy). In C# I would have hosted a bidirectional service and push the information. Also, I plan on having only ONE web page, and just push/update the HTML based on the webservice, I don't know if having routes is the best for that?
    – J4N
    Jan 9, 2017 at 21:21
  • The interaction between Flask and your existing script should be as straightforward as adding an import statement in Flask and calling your existing methods. I made my first shambling steps into Python, from C#, on Flask and it's been relatively painless so far. If you've done a little javascript this example on github might give you a better idea of what a single page site would look like.
    – goobering
    Jan 9, 2017 at 22:27
  • I understand how to make the javascript call to the flask webserver, but how the server will be able to communicate with the other process running the image acquisition? Because if I just import the code, I will have just another instance of it. Or you mean that it's actually my script that will directly host the flask server?
    – J4N
    Jan 10, 2017 at 7:49
  • Python import statements are the equivalent of C# using statements. All you'd be doing is referencing your original script and calling its methods directly from the web server code. All of the code would become part of the same application.
    – goobering
    Jan 10, 2017 at 8:39
  • I understood that, but still, if I've one python script running and one website running, they can use the same code, but then they will have independant instance with independant variables. It's not having an interaction between the two. So with a webserver, how would you have some script that runs in a loop? I don't understand? Because my python script need to run even if there is nobody connected on the website.
    – J4N
    Jan 10, 2017 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.