MCPcopy Create free account
hub / github.com/webpy/webpy / __init__

Method __init__

web/webapi.py:118–134  ·  view source on GitHub ↗

Returns a `status` redirect to the new URL. `url` is joined with the base URL so that things like `redirect("about") will work properly.

(self, url, status="301 Moved Permanently", absolute=False)

Source from the content-addressed store, hash-verified

116 """A `301 Moved Permanently` redirect."""
117
118 def __init__(self, url, status="301 Moved Permanently", absolute=False):
119 """
120 Returns a `status` redirect to the new URL.
121 `url` is joined with the base URL so that things like
122 `redirect("about") will work properly.
123 """
124 newloc = urljoin(ctx.path, url)
125
126 if newloc.startswith("/"):
127 if absolute:
128 home = ctx.realhome
129 else:
130 home = ctx.home
131 newloc = home + newloc
132
133 headers = {"Content-Type": "text/html", "Location": newloc}
134 HTTPError.__init__(self, status, headers, "")
135
136
137redirect = Redirect

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected