Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -708,12 +708,19 @@ loadFavorites(1);
|
|
708 |
# Initialize database on startup
|
709 |
init_db()
|
710 |
|
711 |
-
#
|
712 |
-
|
713 |
-
def setup_db_backup():
|
714 |
# Make sure we have the latest data in both JSON and SQLite
|
715 |
-
urls =
|
716 |
save_json(urls)
|
717 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
718 |
if __name__ == '__main__':
|
719 |
app.run(host='0.0.0.0', port=7860)
|
|
|
708 |
# Initialize database on startup
|
709 |
init_db()
|
710 |
|
711 |
+
# Define a function to ensure database consistency
|
712 |
+
def ensure_db_consistency():
|
|
|
713 |
# Make sure we have the latest data in both JSON and SQLite
|
714 |
+
urls = load_db_sqlite()
|
715 |
save_json(urls)
|
716 |
|
717 |
+
# For Flask 2.0+ compatibility
|
718 |
+
@app.before_request
|
719 |
+
def before_request_func():
|
720 |
+
# Use a flag to run this only once
|
721 |
+
if not hasattr(app, '_got_first_request'):
|
722 |
+
ensure_db_consistency()
|
723 |
+
app._got_first_request = True
|
724 |
+
|
725 |
if __name__ == '__main__':
|
726 |
app.run(host='0.0.0.0', port=7860)
|