Spaces:
Runtime error
Runtime error
only enable scheduler on production
Browse files
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 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
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)
|