File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
tests/arduino/app_bricks/web_ui Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ def webui_server():
1818 f .write ("<html><body>Hello</body></html>" )
1919
2020 ui = WebUI (port = 0 , assets_dir_path = tmp_assets )
21+ def get_hello ():
22+ return {"msg" : "hello" }
23+ ui .expose_api ("GET" , "/api/hello" , get_hello )
24+ def post_echo (data : dict ):
25+ return {"echo" : data .get ("value" )}
26+ ui .expose_api ("POST" , "/api/echo" , post_echo )
2127 ui .start ()
2228
2329 thread = threading .Thread (target = ui .execute , daemon = True )
@@ -38,16 +44,6 @@ def test_http_index(webui_server):
3844
3945
4046def test_expose_api_rest (webui_server ):
41- def get_hello ():
42- return {"msg" : "hello" }
43-
44- webui_server .expose_api ("GET" , "/api/hello" , get_hello )
45-
46- def post_echo (data : dict ):
47- return {"echo" : data .get ("value" )}
48-
49- webui_server .expose_api ("POST" , "/api/echo" , post_echo )
50-
5147 resp = requests .get (f"{ webui_server .url } /api/hello" )
5248 assert resp .status_code == 200
5349 assert resp .json () == {"msg" : "hello" }
You can’t perform that action at this time.
0 commit comments