After calling the init_led() method to initiate and default out GPIOZero led instance, we then see how to register our LEDControl resource with api.add_resource() on line (19). Here, we are mapping the URL endpoint, /led, with our controller.
Notice, in the code block on line (19), we have api.add_resource(...). The presence of the api variable means we are using and configuring the Flask-RESTful extension here.
Finally, on line (20), our server is started (in debug mode) and is ready to receive client requests. Notice that we use the core Flask instance in the app variable to start the server:
# Initialize Module.
init_led()
api.add_resource(LEDControl, '/led') # (19)
if __name__ == '__main__':
app.run(host="0.0.0.0", debug=True) # (20)
Well done! We've just covered the build of a simple, yet, functional RESTful API server in Python...