Spaces:
sahanind
/
No application file

sahanind commited on
Commit
be73ed9
·
verified ·
1 Parent(s): 6a1b3ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -17
app.py CHANGED
@@ -29,7 +29,7 @@ api_hash = str(api_hash)
29
  bot_token = str(btoken)
30
  channel= int(chnl)
31
 
32
-
33
 
34
  ###DB BACKUP##
35
 
@@ -43,11 +43,17 @@ async def downdb():
43
  last_message = event.message
44
  await fast_download(client,last_message)
45
  await client.disconnect()
46
- db = SQLAlchemy(app)
47
- migrate = Migrate(app, db)
48
  return '2'
49
 
50
 
 
 
 
 
 
 
 
51
  async def updb():
52
  client = TelegramClient(None, api_id, api_hash)
53
  await client.start(bot_token=bot_token)
@@ -505,20 +511,7 @@ def new_conversation():
505
 
506
 
507
 
508
- @app.route('/downdb', methods=['GET'])
509
- @login_required
510
- def downdbur():
511
- # Create a new event loop for the current thread
512
- loop = asyncio.new_event_loop()
513
- asyncio.set_event_loop(loop)
514
- db.session.remove()
515
- # Run the async function
516
- rp = loop.run_until_complete(downdb())
517
- loop.close() # Close the loop when done
518
-
519
- if rp == '2':
520
- return '200'
521
- return 'no'
522
 
523
 
524
  @app.route('/updb', methods=['GET'])
 
29
  bot_token = str(btoken)
30
  channel= int(chnl)
31
 
32
+ print('dl sec')
33
 
34
  ###DB BACKUP##
35
 
 
43
  last_message = event.message
44
  await fast_download(client,last_message)
45
  await client.disconnect()
46
+
 
47
  return '2'
48
 
49
 
50
+ loop = asyncio.new_event_loop()
51
+ asyncio.set_event_loop(loop)
52
+ db.session.remove()
53
+ rp = loop.run_until_complete(downdb())
54
+ loop.close() # Close the loop when done
55
+ print('done')
56
+
57
  async def updb():
58
  client = TelegramClient(None, api_id, api_hash)
59
  await client.start(bot_token=bot_token)
 
511
 
512
 
513
 
514
+
 
 
 
 
 
 
 
 
 
 
 
 
 
515
 
516
 
517
  @app.route('/updb', methods=['GET'])