MCPcopy Index your code
hub / github.com/plotly/dash / pathname_configs

Function pathname_configs

dash/_configs.py:62–126  ·  view source on GitHub ↗
(
    url_base_pathname=None, routes_pathname_prefix=None, requests_pathname_prefix=None
)

Source from the content-addressed store, hash-verified

60
61
62def pathname_configs(
63 url_base_pathname=None, routes_pathname_prefix=None, requests_pathname_prefix=None
64):
65 _pathname_config_error_message = """
66 {} This is ambiguous.
67 To fix this, set `routes_pathname_prefix` instead of `url_base_pathname`.
68
69 Note that `requests_pathname_prefix` is the prefix for the AJAX calls that
70 originate from the client (the web browser) and `routes_pathname_prefix` is
71 the prefix for the API routes on the backend (this flask server).
72 `url_base_pathname` will set `requests_pathname_prefix` and
73 `routes_pathname_prefix` to the same value.
74 If you need these to be different values then you should set
75 `requests_pathname_prefix` and `routes_pathname_prefix`,
76 not `url_base_pathname`.
77 """
78 url_base_pathname = get_combined_config("url_base_pathname", url_base_pathname)
79
80 routes_pathname_prefix = get_combined_config(
81 "routes_pathname_prefix", routes_pathname_prefix
82 )
83
84 requests_pathname_prefix = get_combined_config(
85 "requests_pathname_prefix", requests_pathname_prefix
86 )
87
88 if url_base_pathname is not None and requests_pathname_prefix is not None:
89 raise exceptions.InvalidConfig(
90 _pathname_config_error_message.format(
91 "You supplied `url_base_pathname` and `requests_pathname_prefix`."
92 )
93 )
94
95 if url_base_pathname is not None and routes_pathname_prefix is not None:
96 raise exceptions.InvalidConfig(
97 _pathname_config_error_message.format(
98 "You supplied `url_base_pathname` and `routes_pathname_prefix`."
99 )
100 )
101
102 if url_base_pathname is not None and routes_pathname_prefix is None:
103 routes_pathname_prefix = url_base_pathname
104 elif routes_pathname_prefix is None:
105 routes_pathname_prefix = "/"
106
107 if not routes_pathname_prefix.startswith("/"):
108 raise exceptions.InvalidConfig(
109 "`routes_pathname_prefix` needs to start with `/`"
110 )
111 if not routes_pathname_prefix.endswith("/"):
112 raise exceptions.InvalidConfig("`routes_pathname_prefix` needs to end with `/`")
113
114 app_name = load_dash_env_vars().DASH_APP_NAME
115
116 if not requests_pathname_prefix and app_name:
117 requests_pathname_prefix = "/" + app_name + routes_pathname_prefix
118 elif requests_pathname_prefix is None:
119 requests_pathname_prefix = routes_pathname_prefix

Calls 3

get_combined_configFunction · 0.85
load_dash_env_varsFunction · 0.85
formatMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…