I am a beginner Pythoon programmer working on the setup of a Flask video server based on [this tutorial](https://blog.miguelgrinberg.com/post/video-streaming-with-flask). The bit of code I have a problem with is used to initialize the computer webcam and output the frames :

```
class Camera(object):
    thread = None  # background thread that reads frames from camera
    frame = None  # current frame is stored here by background thread
    last_access = 0  # time of last client access to the camera
    start_time = 0  # time at which the camera is started

    def __init__(self):
        """Start the background camera thread if it isn't running yet."""
        ...

    def get_frame(self):
        """Return the current camera frame."""
        ...

    @staticmethod
    def frames():
        """"Generator that returns frames from the camera."""
        ...

    @classmethod
    def _thread(cls):
        """Camera background thread."""
        ...

```

It does not make sense to me to use a class for this, since there should only be one instance of the Camera object. Because of this, every time a request is made to the server, a new object is a created for no reason.

I've looked at possible ways to refactor this. What I've found so far :

* Use a singleton class, but that does not seem recommended in Python
* Put everything in a separate module. Then all the class variables would become global variables, and that's bad from what I've read