def handle_complex_resource_path(path, root, resource):
# Handle complex endpoint. Twisted expects byte-type URIs.
fullpath = path.encode('utf-8').split(b'/')
parent_path_item_resource = root
for path_item in fullpath:
if path_item == fullpath[-1]:
parent_path_item_resource.putChild(path_item, resource)
else:
new_resource = Resource()
parent_path_item_resource.putChild(path_item, new_resource)
parent_path_item_resource = new_resource
# =============================================================================
# Start webserver
# =============================================================================
评论列表
文章目录