async def phone(phone_number: str, user_agent: Optional[str] = Header(None)): print("User-Agent", user_agent) if re.findall("Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone", user_agent): return responses.RedirectResponse(f"tel:{phone_number}", status_code=302) return responses.Response("Please use you phone to call number.")
async def oauth_redirect(request: Request, path: str, state: str = ""): target_domain, _, _ = state.partition("|") path = f"/{path}" if not is_valid(target_domain, path): log.info("unauthorized domain=%s path=%s", target_domain, path) raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST) full_url = f"https://{target_domain}{path}" return responses.RedirectResponse(full_url, status_code=302)
async def disclose_view(url: str = Form(""), payload: str = Form("")): state["url"]["value"] = url state["payload"]["value"] = payload errors = False # Not checking anything on payload to leave all the room for testing edcases # (missing or malformed body) if not payload: state["payload"]["error"] = "Missing url" errors = True if not errors: state["response"] = await disclose(url=url, payload=payload) state["url"]["error"] = False state["payload"]["error"] = False return responses.RedirectResponse("/", status_code=302)
async def edit_key_view( i: int, action: str = Form(...), ): keys = state["keys"] redir = responses.RedirectResponse("/", status_code=302) if not 0 <= i < len(keys): return redir if action == "up" and i != 0: keys.insert(i - 1, keys.pop(i)) if action == "down" and i != len(keys) - 1: keys.insert(i + 1, keys.pop(i)) if action == "delete": k = keys.pop(i) if keys and k["is_current"]: keys[0]["is_current"] = True if action == "current": for j, k in enumerate(keys): k["is_current"] = i == j return redir
async def home(): return responses.RedirectResponse('/docs')
async def add_key_view(): create_keypair() return responses.RedirectResponse("/", status_code=302)
def facivon(): return responses.RedirectResponse(url="/mealie/favicon.ico")
async def email(email: str, user_agent: Optional[str] = Header(None)): print("User-Agent", user_agent) if re.findall("Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone", user_agent): return responses.RedirectResponse(f"mailto:{email}", status_code=302) return responses.Response("Please use you phone to write email.")
async def get_root(): return responses.RedirectResponse( f"{ROOT_PATH}/docs", status_code=status.HTTP_301_MOVED_PERMANENTLY)