Skip to content

Commit d48c3b7

Browse files
committed
better routing
1 parent 5a57eab commit d48c3b7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

gurgleapps_webserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def get_path_components(self, path):
148148
def match_route(self, path_components):
149149
for route in self.function_routes:
150150
route_pattern = list(filter(None, route["route"].split("/")))
151-
print("route_pattern: "+str(route_pattern))
151+
#print("route_pattern: "+str(route_pattern))
152152
if len(route_pattern) != len(path_components):
153153
continue
154154
match = True

main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ async def example_func(request, response, param1, param2):
1616
response_string = json.dumps({ "param1": param1, "param2": param2, "post_data": request.post_data})
1717
await response.send_json(response_string, 200)
1818

19-
19+
async def say_hello(request, response, name):
20+
await response.send_html("Hello " + name + " hope you are well")
2021

2122
async def send_status(request, response):
2223
# send boolean status and number frequency
@@ -62,5 +63,6 @@ async def run():
6263
server.add_function_route("/start", start_flashing)
6364
server.add_function_route("/status", send_status)
6465
server.add_function_route("/example/func/<param1>/<param2>", example_func)
66+
server.add_function_route("/hello/<name>", say_hello)
6567

6668
asyncio.run(run())

0 commit comments

Comments
 (0)