File size: 751 Bytes
9c4e7c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
set -euo pipefail

# /data jest montowane przez HF; jeśli nie mamy uprawnień, pomiń
if [ ! -d /data ]; then
  echo "Info: /data not available (will be mounted by Spaces)."
fi

: "${DATABASE_URL:?ERROR: DATABASE_URL is not set}"

python - <<'PY'
import os
from sqlalchemy import create_engine, text
engine = create_engine(os.environ["DATABASE_URL"], pool_pre_ping=True)
with engine.begin() as conn:
    conn.execute(text("""

        CREATE TABLE IF NOT EXISTS notes (

            id SERIAL PRIMARY KEY,

            body TEXT NOT NULL,

            created_at TIMESTAMPTZ DEFAULT now()

        )

    """))
PY

# Start aplikacji – dopasuj do swojej
exec python server.py
# (albo: exec python server.py)