The post() class method handles HTTP POST requests made to the LEDControl resource. It is this post() method that received and processed our curl POST request when we made the following request earlier when we tested our server:
curl -X POST -d '{"level": 100}' \
-H "Content-Type: application/json" \
http://localhost:5000/led
post() is more complex than our get() method. It is here where we change the brightness of our LED in response to a requesting client's input:
def post(self):
"""Handles HTTP POST requests to set LED brightness level."""
global state # (14)
args = self.args_parser.parse_args() # (15)
# Set PWM duty cycle to adjust brightness level.
state['level'] = args.level # (16)
led.value = state['level'] / 100 ...