minimal visual improvements

This commit is contained in:
2025-12-15 23:07:46 +10:00
parent 661fee131e
commit f18f545e33

View File

@@ -15,12 +15,23 @@ app = FastAPI(
openapi_url=None # Disable OpenAPI JSON schema
)
STYLES = """
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
}
</style>
"""
@app.get("/register", response_class=HTMLResponse)
async def register_form():
return """
return f"""
<html>
<head><title>Регистрация</title></head>
<head><title>Регистрация</title>{STYLES}</head>
<body>
<h2>Регистрация</h2>
<form action="/register" method="post">
@@ -43,9 +54,9 @@ async def register(login: str = Form(...), password: str = Form(...)):
response.set_cookie("password", password)
return response
except sqlite3.IntegrityError:
return HTMLResponse("""
return HTMLResponse(f"""
<html>
<head><title>Ошибка регистрации</title></head>
<head><title>Ошибка регистрации</title>{STYLES}</head>
<body>
<h3>Login уже существует</h3>
<a href='/register'>Попробовать снова</a>
@@ -55,9 +66,9 @@ async def register(login: str = Form(...), password: str = Form(...)):
@app.get("/login", response_class=HTMLResponse)
async def login_form():
return """
return f"""
<html>
<head><title>Вход</title></head>
<head><title>Вход</title>{STYLES}</head>
<body>
<h2>Вход</h2>
<form action="/login" method="post">
@@ -80,9 +91,9 @@ async def login(login: str = Form(...), password: str = Form(...)):
response.set_cookie("password", password)
return response
else:
return HTMLResponse("""
return HTMLResponse(f"""
<html>
<head><title>Ошибка входа</title></head>
<head><title>Ошибка входа</title>{STYLES}</head>
<body>
<h3>Неверные учетные данные</h3>
<a href='/login'>Попробовать снова</a>
@@ -101,7 +112,7 @@ async def welcome(request: Request):
if user:
return f"""
<html>
<head><title>Добро пожаловать</title></head>
<head><title>Добро пожаловать</title>{STYLES}</head>
<body>
<h1>Привет, {login}</h1>
<form action="/logout" method="post" onsubmit="return logoutAlert();">