radames commited on
Commit
cd1b7e7
β€’
1 Parent(s): ec97e73

only enable scheduler on production

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -38,7 +38,6 @@ db = sqlite3.connect(DB_FILE)
38
  try:
39
  data = db.execute("SELECT * FROM prompts").fetchall()
40
  db.close()
41
- print("DB DATA", data)
42
  except sqlite3.OperationalError:
43
  db.execute('CREATE TABLE prompts (guess TEXT, correct TEXT)')
44
  db.commit()
@@ -99,9 +98,14 @@ def create():
99
  except:
100
  return 'Missing guess or correct', 400
101
 
 
102
  if __name__ == '__main__':
103
- scheduler = APScheduler()
104
- scheduler.add_job(id = 'Update Dataset Repository', func = update_repository, trigger = 'interval', seconds = 300)
105
- scheduler.start()
 
 
 
 
106
  app.run(host='0.0.0.0', port=int(
107
  os.environ.get('PORT', 7860)), debug=True)
 
38
  try:
39
  data = db.execute("SELECT * FROM prompts").fetchall()
40
  db.close()
 
41
  except sqlite3.OperationalError:
42
  db.execute('CREATE TABLE prompts (guess TEXT, correct TEXT)')
43
  db.commit()
 
98
  except:
99
  return 'Missing guess or correct', 400
100
 
101
+
102
  if __name__ == '__main__':
103
+ mode = os.environ.get('FLASK_ENV', 'production')
104
+ print(mode)
105
+ if mode != 'development':
106
+ scheduler = APScheduler()
107
+ scheduler.add_job(id='Update Dataset Repository',
108
+ func=update_repository, trigger='interval', seconds=300)
109
+ scheduler.start()
110
  app.run(host='0.0.0.0', port=int(
111
  os.environ.get('PORT', 7860)), debug=True)