-
Автор темы
- #1
fasapi постоянно выдает ошибку "POST /login HTTP/1.1" 422 Unprocessable Entity при попытке таким макаром достать код с формы
Код:
@router.get('/')
def get_base_page(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
@app.post("/login")
async def login(request: Request, signup_username: str = Form(None), signup_email: str = Form(None), signup_password: str = Form(None), login_email: str = Form(None), login_password: str = Form(None)):
return templates.TemplateResponse("login.html", {"request": request})
Код:
<!DOCTYPE html>
<html>
<head>
<title>Сокращатель ссылок</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', path='/login.css') }}">
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@500&display=swap" rel="stylesheet">
</head>
<body>
<div class="main">
<input type="checkbox" id="chk" aria-hidden="true">
<div class="signup">
<form action="/login" method="post">
<label for="chk" aria-hidden="true">Sign up</label>
<input type="text" name="signup_username" id="signup_username" placeholder="User name">
<input type="email" name="signup_email" id="signup_email" placeholder="Email">
<input type="password" name="signup_password" id="signup_password" placeholder="Password">
<button>Sign up</button>
</form>
</div>
<div class="login">
<form action="/login" method="post">
<label for="chk" aria-hidden="true">Login</label>
<input type="email" name="login_email" id="login_email" placeholder="Email">
<input type="password" name="login_password" id="login_password" placeholder="Password">
<button>Login</button>
</form>
</div>
</div>
</body>
</html>