MCPcopy
hub / github.com/pallets/werkzeug / on_new_url

Method on_new_url

examples/shortly/shortly.py:57–67  ·  view source on GitHub ↗
(self, request)

Source from the content-addressed store, hash-verified

55 )
56
57 def on_new_url(self, request):
58 error = None
59 url = ""
60 if request.method == "POST":
61 url = request.form["url"]
62 if not is_valid_url(url):
63 error = "Please enter a valid URL"
64 else:
65 short_id = self.insert_url(url)
66 return redirect(f"/{short_id}+")
67 return self.render_template("new_url.html", error=error, url=url)
68
69 def on_follow_short_link(self, request, short_id):
70 link_target = self.redis.get(f"url-target:{short_id}")

Callers

nothing calls this directly

Calls 4

insert_urlMethod · 0.95
render_templateMethod · 0.95
redirectFunction · 0.90
is_valid_urlFunction · 0.85

Tested by

no test coverage detected