Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def app(scope, receive, send):
if scope["path"] == "/":
response = Response("hello, world", media_type="text/plain")
else:
response = RedirectResponse("/")
await response(scope, receive, send)
def get_pathlist(uri: str) -> typing.List[str]:
if uri.endswith("/index"):
return RedirectResponse(f'/{uri[:-len("/index")]}', status_code=301)
if uri.endswith("/"):
uri += "index"
filepath = uri[1:].strip(".")
# Google SEO
if not config.ALLOW_UNDERLINE:
if "_" in uri:
return RedirectResponse(f'/{uri.replace("_", "-")}', status_code=301)
filepath = filepath.replace("-", "_")
# judge python file
abspath = os.path.join(config.path, "views", filepath + ".py")
if not os.path.exists(abspath):
raise HTTPException(404)
pathlist = filepath.split("/")
pathlist.insert(0, "views")
return pathlist
def trailingslash_redirect(self, request):
return RedirectResponse(request.url.path + "/")
if not form.validate():
context.update({"form": form, "object": instance})
return config.templates.TemplateResponse(cls.delete_template, context)
try:
await cls.do_delete(instance, form, request)
message(request, "Deleted successfully", "success")
except IntegrityError:
message(
request,
"Could not be deleted due to being referenced by a related object",
"error",
)
return RedirectResponse(
url=request.url_for(cls.url_names()["list"]), status_code=302
)
active = request.query_params.get("active", False)
res = es.search(
index=settings.ES_INDEX,
doc_type=settings.ES_TYPE,
size=1,
body=random_query(active, "Registered Charity"),
ignore=[404]
)
char = None
if "hits" in res:
if "hits" in res["hits"]:
char = res["hits"]["hits"][0]
if char:
if filetype == "html":
return RedirectResponse(request.url_for('orgid_html', orgid=char["_id"]))
return JSONResponse(char["_source"])
async def well_known():
"""Alias for /void/"""
return RedirectResponse(url="/void/")
def docs_redirect():
return RedirectResponse(f"{prefix}/docs")
)
if resp.errors:
LOG.error(f'{resp.errors}')
raise Exception('Unable to login user')
LOG.info(f'Auth Response: {resp.data}')
token = resp.data['login']
user = set_user(
username=token['user']['name'],
auth_token=token['authToken'],
catalog=token['catalog'],
roles=token['roles']
)
response = RedirectResponse('/dashboard')
response.set_cookie(SESSION_COOKE_NAME, user.session_id)
return response
def get_pathlist(uri: str) -> typing.List[str]:
if uri.endswith("/index"):
return RedirectResponse(f'/{uri[:-len("/index")]}', status_code=301)
if uri.endswith("/"):
uri += "index"
filepath = uri[1:].strip(".")
# Google SEO
if not config.ALLOW_UNDERLINE:
if "_" in uri:
return RedirectResponse(f'/{uri.replace("_", "-")}', status_code=301)
filepath = filepath.replace("-", "_")
# judge python file
abspath = os.path.join(config.path, "views", filepath + ".py")
if not os.path.exists(abspath):
raise HTTPException(404)