Spaces:
sahanind
/
No application file

sahanind commited on
Commit
2adf9d4
·
verified ·
1 Parent(s): c37604b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -27,6 +27,23 @@ bot_token = str(btoken)
27
  channel= int(chnl)
28
 
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  app = Flask("Simplz")
31
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
32
  app.config['SECRET_KEY'] = 'your_secret_key'
@@ -471,6 +488,24 @@ def new_conversation():
471
  return render_template('new_conversation.html')
472
 
473
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
 
475
  @app.route('/conversation/<int:recipient_id>', methods=['GET', 'POST'])
476
  @login_required
 
27
  channel= int(chnl)
28
 
29
 
30
+ ###DB BACKUP##
31
+
32
+ def downdb(msgid):
33
+ os.remove('instance/database.db')
34
+ client = TelegramClient(None, api_id, api_hash)
35
+ await fast_download(client,msgid)
36
+ return '2'
37
+
38
+
39
+ def updb():
40
+ client = TelegramClient(None, api_id, api_hash)
41
+ await client.start(bot_token=bot_token)
42
+ path = 'instance/database.db'
43
+ fle = await fast_upload(client, file_location=path)
44
+ await client.send_file(channel,fle, force_document=True)
45
+ return '2'
46
+
47
  app = Flask("Simplz")
48
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
49
  app.config['SECRET_KEY'] = 'your_secret_key'
 
488
  return render_template('new_conversation.html')
489
 
490
 
491
+ @app.route('/downdb', methods=['GET'])
492
+ @login_required
493
+ msgid = request.args.get('msg', '')
494
+ def downdbur():
495
+ rp = downdb(msgid)
496
+ if rp=='2':
497
+ return '200'
498
+ return 'no'
499
+
500
+ @app.route('/updb', methods=['GET'])
501
+ @login_required
502
+ def updbur():
503
+ rp = updb()
504
+ if rp=='2':
505
+ return '200'
506
+ return 'no'
507
+
508
+
509
 
510
  @app.route('/conversation/<int:recipient_id>', methods=['GET', 'POST'])
511
  @login_required