Aktualizovat sk1/backend/app.py
This commit is contained in:
parent
55dc649360
commit
fb91012c70
@ -16,12 +16,12 @@ CORS(app)
|
|||||||
app.config['CACHE_TYPE'] = 'SimpleCache'
|
app.config['CACHE_TYPE'] = 'SimpleCache'
|
||||||
cache = Cache(app)
|
cache = Cache(app)
|
||||||
|
|
||||||
# Database connection
|
|
||||||
DATABASE_URL = os.environ.get('DATABASE_URL')
|
DATABASE_URL = os.environ.get('DATABASE_URL')
|
||||||
conn = psycopg2.connect(DATABASE_URL)
|
conn = psycopg2.connect(DATABASE_URL)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
# Initialize DB
|
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
CREATE TABLE IF NOT EXISTS history (
|
CREATE TABLE IF NOT EXISTS history (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
@ -47,7 +47,7 @@ def get_current_time():
|
|||||||
return datetime.now(tz)
|
return datetime.now(tz)
|
||||||
|
|
||||||
def sync_history_file():
|
def sync_history_file():
|
||||||
# Synchronizácia history.json so všetkými záznamami z databázy
|
|
||||||
cursor.execute("SELECT text, prediction, timestamp FROM history ORDER BY timestamp DESC")
|
cursor.execute("SELECT text, prediction, timestamp FROM history ORDER BY timestamp DESC")
|
||||||
rows = cursor.fetchall()
|
rows = cursor.fetchall()
|
||||||
history = [
|
history = [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user