99status = True
1010led = Pin ("LED" , Pin .OUT )
1111
12- async def example_func (response , param1 , param2 ):
12+ async def example_func (request , response , param1 , param2 ):
1313 print ("example_func" )
1414 print ("param1: " + param1 )
1515 print ("param2: " + param2 )
16- response_string = json .dumps ({"param1" : param1 , "param2" : param2 })
16+ response_string = json .dumps ({ "param1" : param1 , "param2" : param2 , "post_data" : request . post_data })
1717 await response .send ("200 OK" , "application/json" , response_string )
1818
1919
2020
21- async def send_status (response ):
21+ async def send_status (request , response ):
2222 # send boolean status and number frequency
2323 response_string = json .dumps ({"status" : status , "delay" : delay })
2424 await response .send ("200 OK" , "application/json" , response_string )
2525
2626
27- async def set_delay (response , new_delay ):
27+ async def set_delay (request , response , new_delay ):
2828 print ("new delay: " + new_delay )
2929 global delay
3030 delay = float (new_delay )
31- await send_status (response )
31+ await send_status (request , response )
3232
33- async def stop_flashing (response ):
33+ async def stop_flashing (request , response ):
3434 global status
3535 status = False
36- await send_status (response )
36+ await send_status (request , response )
3737
38- async def start_flashing (response ):
38+ async def start_flashing (request , response ):
3939 global status
4040 status = True
41- await send_status (response )
41+ await send_status (request , response )
4242
4343async def main ():
4444 await server .start_server ()
@@ -63,10 +63,4 @@ async def run():
6363server .add_function_route ("/status" , send_status )
6464server .add_function_route ("/example/func/<param1>/<param2>" , example_func )
6565
66- """ server.add_function_route("^/set-delay/(\d+(?:\.\d+)?)$", set_delay) #23.78 2 23 float
67- server.add_function_route("^/stop$", stop_flashing)
68- server.add_function_route("^/start$", start_flashing)
69- server.add_function_route("^/status$", send_status) """
70-
71-
7266asyncio .run (run ())
0 commit comments