-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (27 loc) · 787 Bytes
/
main.py
File metadata and controls
33 lines (27 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import eventlet
eventlet.monkey_patch()
from app import app, socketio, db, sync_article_counts
import threading
from scheduler import start_scheduler
def run_scheduler():
start_scheduler()
if __name__ == "__main__":
# Initialize database within app context
with app.app_context():
try:
db.create_all()
sync_article_counts()
except Exception as e:
print(f"Database initialization error: {e}")
# Start scheduler in a separate thread
scheduler_thread = threading.Thread(target=run_scheduler)
scheduler_thread.daemon = True
scheduler_thread.start()
# Start the application
socketio.run(
app,
host='0.0.0.0',
port=5000,
debug=False,
use_reloader=False
)