Update app.py
Browse files
app.py
CHANGED
|
@@ -5,16 +5,16 @@ import os
|
|
| 5 |
from flask_cors import CORS
|
| 6 |
|
| 7 |
app = Flask(__name__)
|
| 8 |
-
CORS(app)
|
| 9 |
|
| 10 |
-
# ✅ Use
|
| 11 |
-
DATA_DIR = '
|
| 12 |
DATA_FILE = os.path.join(DATA_DIR, 'events.json')
|
| 13 |
|
| 14 |
-
# ✅ Ensure the
|
| 15 |
os.makedirs(DATA_DIR, exist_ok=True)
|
| 16 |
|
| 17 |
-
# ✅
|
| 18 |
if not os.path.exists(DATA_FILE):
|
| 19 |
with open(DATA_FILE, 'w') as f:
|
| 20 |
json.dump([], f)
|
|
|
|
| 5 |
from flask_cors import CORS
|
| 6 |
|
| 7 |
app = Flask(__name__)
|
| 8 |
+
CORS(app)
|
| 9 |
|
| 10 |
+
# ✅ Use Hugging Face's writable temp directory
|
| 11 |
+
DATA_DIR = '/tmp/data'
|
| 12 |
DATA_FILE = os.path.join(DATA_DIR, 'events.json')
|
| 13 |
|
| 14 |
+
# ✅ Ensure the /tmp/data directory exists
|
| 15 |
os.makedirs(DATA_DIR, exist_ok=True)
|
| 16 |
|
| 17 |
+
# ✅ Create the events.json file if it doesn't exist
|
| 18 |
if not os.path.exists(DATA_FILE):
|
| 19 |
with open(DATA_FILE, 'w') as f:
|
| 20 |
json.dump([], f)
|