feat: initial Flask skeleton with PostgreSQL

This commit is contained in:
Ivan Budakov 2026-10-19 17:29:04 +03:00
commit a1b966a22b
8 changed files with 103 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
venv/
__pycache__/
*.pyc

0
app/__init__.py Normal file
View File

12
app/config.py Normal file
View File

@ -0,0 +1,12 @@
import os
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
POSTGRES_USER = os.getenv("POSTGRES_USER", "morozovka")
POSTGRES_PASSWORD = os.getenv("POSTGRES_PASSWORD", "rf-slf-1945")
POSTGRES_DB = os.getenv("POSTGRES_DB", "morozovka_portal")
POSTGRES_HOST = os.getenv("POSTGRES_HOST", "127.0.0.1")
POSTGRES_PORT = os.getenv("POSTGRES_PORT", "5432")
DATABASE_URL = f"postgresql+psycopg2://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_HOST}:{POSTGRES_PORT}/{POSTGRES_DB}"

8
app/db.py Normal file
View File

@ -0,0 +1,8 @@
from sqlmodel import SQLModel, create_engine
from .config import DATABASE_URL
engine = create_engine(DATABASE_URL, echo=False)
def init_db():
"""Создает все таблицы в БД."""
SQLModel.metadata.create_all(engine)

18
app/main.py Normal file
View File

@ -0,0 +1,18 @@
from flask import Flask, render_template, jsonify
from .db import init_db
app = Flask(__name__)
# Инициализируем БД при старте (в будущем заменим на Alembic миграции)
with app.app_context():
init_db()
@app.route("/healthz")
def healthz():
"""Проверка жизнеспособности сервиса."""
return jsonify({"status": "ok", "service": "morozovka-portal"})
@app.route("/")
def index():
"""Главная страница портала."""
return render_template("index.html")

3
app/models.py Normal file
View File

@ -0,0 +1,3 @@
from sqlmodel import SQLModel
# Здесь будут модели User, Project и т.д.

43
app/templates/index.html Normal file
View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Morozovka Portal</title>
<style>
body {
background: #0d1117;
color: #e6edf3;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
flex-direction: column;
}
h1 {
font-size: 2.5rem;
margin-bottom: 10px;
background: linear-gradient(90deg, #58a6ff, #a371f7, #f778ba);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
p { color: #8b949e; }
.badge {
background: #238636;
color: white;
padding: 5px 10px;
border-radius: 5px;
font-size: 0.8rem;
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Morozovka Portal</h1>
<p>Скелет системы успешно запущен! (Flask Edition)</p>
<div class="badge">Stage 1.2: OK</div>
</body>
</html>

16
requirements.txt Normal file
View File

@ -0,0 +1,16 @@
annotated-types==0.8.0
blinker==1.9.0
click==8.5.0
Flask==3.1.3
gunicorn==26.2.0
itsdangerous==2.2.0
Jinja2==3.1.6
MarkupSafe==3.0.4
psycopg2-binary==2.9.13
pydantic==2.14.1
pydantic_core==2.50.1
SQLAlchemy==2.1.5
sqlmodel==0.0.48
typing-inspection==0.4.4
typing_extensions==4.16.0
Werkzeug==3.1.9