show me the code...
from django.urls import URLPattern
def get_all_urls(patterns, pre_fix, result):
for item in patterns:
part = item.pattern.regex.pattern.strip("^$")
if isinstance(item, URLPattern):
result.append(pre_fix + part)
else:
get_all_urls(item.url_patterns, pre_fix + part, result=result)
return result
if __name == "__main__":
# 项目根路由
from server import urls
print(get_all_urls(urls.urlpatterns, pre_fix="/", result=[]))
by max.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。