Spaces:
sahanind
/
No application file

sahanind commited on
Commit
9dd23c4
·
verified ·
1 Parent(s): 4c77d86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -556,11 +556,19 @@ def conversation(recipient_id):
556
 
557
 
558
 
559
- if __name__ == '__main__':
560
- loop = asyncio.new_event_loop()
561
- asyncio.set_event_loop(loop)
562
- rp = loop.run_until_complete(downdb())
563
- # loop.close()
564
  with app.app_context():
565
  db.create_all()
566
  app.run(debug=True, use_reloader=False, host="0.0.0.0", port=7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
556
 
557
 
558
 
559
+ def start_flask_app():
 
 
 
 
560
  with app.app_context():
561
  db.create_all()
562
  app.run(debug=True, use_reloader=False, host="0.0.0.0", port=7860)
563
+
564
+ if __name__ == '__main__':
565
+ loop = asyncio.new_event_loop()
566
+ asyncio.set_event_loop(loop)
567
+ try:
568
+ # Run the async task
569
+ loop.run_until_complete(downdb())
570
+ finally:
571
+ loop.close()
572
+
573
+ # Now start the Flask app after async task finishes
574
+ start_flask_app()