def shortner(self) -> FlaskResponse: # pylint: disable=no-self-use url = request.form.get("data") obj = models.Url(url=url) db.session.add(obj) db.session.commit() return Response( "{scheme}://{request.headers[Host]}/r/{obj.id}".format( scheme=request.scheme, request=request, obj=obj), mimetype="text/plain", )
def shortner(self) -> FlaskResponse: url = request.form.get("data") if not self._validate_url(url): logger.warning("Invalid URL: %s", url) return Response("Invalid URL", 400) obj = models.Url(url=url) db.session.add(obj) db.session.commit() return Response( "{scheme}://{request.headers[Host]}/r/{obj.id}".format( scheme=request.scheme, request=request, obj=obj), mimetype="text/plain", )