triflix commited on
Commit
98dc217
·
verified ·
1 Parent(s): 2609650

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -5,16 +5,16 @@ import os
5
  from flask_cors import CORS
6
 
7
  app = Flask(__name__)
8
- CORS(app) # Enable CORS for all routes
9
 
10
- # ✅ Use a writable local data directory
11
- DATA_DIR = './data'
12
  DATA_FILE = os.path.join(DATA_DIR, 'events.json')
13
 
14
- # ✅ Ensure the ./data directory exists
15
  os.makedirs(DATA_DIR, exist_ok=True)
16
 
17
- # ✅ Initialize events.json 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)
 
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)