ip сервера

This commit is contained in:
2026-03-03 20:15:58 +10:00
parent 9a1db33e53
commit 88b7656e20

26
main.py
View File

@@ -211,6 +211,32 @@ def get_records():
if conn:
conn.close()
@app.get("/records_all_status", summary="Получить все записи избранного", response_model=List[ParsedData])
def get_records():
"""
Возвращает записи из таблицы url с избранным.
"""
conn = None
try:
conn = get_connection()
with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
cur.execute("""
SELECT url, parsed_at, title, original_text, article_date, status, viewed, other, category, translation_text, short_text
FROM url
WHERE status = true
ORDER BY parsed_at DESC
""")
rows = cur.fetchall()
results = [dict(row) for row in rows]
urls = [item['parsed_at'] for item in results]
print(urls)
return results
except Exception as e:
raise HTTPException(status_code=500, detail=f"Ошибка при получении записей из БД: {e}")
finally:
if conn:
conn.close()
# get_records()