Hashir Kashif commited on
Commit
af4a00b
·
1 Parent(s): 141cbfe

editing99999990999asasdasdasdasasdasddasdasdasdasasdasdasd

Browse files
Files changed (3) hide show
  1. app.py +21 -0
  2. requirements.txt +2 -1
  3. sftp_test.py +20 -0
app.py CHANGED
@@ -13,6 +13,7 @@ from threading import Thread
13
  import time
14
  import json
15
  from urllib.parse import unquote
 
16
  os.remove("./cookies/test.txt")
17
 
18
  class Unbuffered(object):
@@ -251,6 +252,26 @@ def backupNoMembership():
251
  thr.start()
252
  # mainTask()
253
  return 'Backup Started of NoMemberhship'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
 
256
  ppath = "/"
 
13
  import time
14
  import json
15
  from urllib.parse import unquote
16
+ import paramiko
17
  os.remove("./cookies/test.txt")
18
 
19
  class Unbuffered(object):
 
252
  thr.start()
253
  # mainTask()
254
  return 'Backup Started of NoMemberhship'
255
+ @app.route('/sftp_test')
256
+ def sftp_test():
257
+ ssh_client = paramiko.SSHClient()
258
+
259
+ # remote server credentials
260
+ host = "s1.serv00.com"
261
+ username = "hashir672"
262
+ password = "gVlwXbMsxPAA36%!OSIm"
263
+ port = 22
264
+
265
+ ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
266
+ ssh_client.connect(hostname=host,port=port,username=username,password=password)
267
+ ftp = ssh_client.open_sftp()
268
+ files = ftp.listdir()
269
+
270
+ print("Listing all the files and Directory: ",files)
271
+ # print('connection established successfully')
272
+
273
+ ssh_client.close()
274
+ return str(files)
275
 
276
 
277
  ppath = "/"
requirements.txt CHANGED
@@ -3,4 +3,5 @@ gunicorn
3
  requests
4
  bs4
5
  deep_translator
6
- flask_autoindex
 
 
3
  requests
4
  bs4
5
  deep_translator
6
+ flask_autoindex
7
+ paramiko
sftp_test.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import paramiko
2
+
3
+ # create ssh client
4
+ ssh_client = paramiko.SSHClient()
5
+
6
+ # remote server credentials
7
+ host = "s1.serv00.com"
8
+ username = "hashir672"
9
+ password = "gVlwXbMsxPAA36%!OSIm"
10
+ port = 22
11
+
12
+ ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
13
+ ssh_client.connect(hostname=host,port=port,username=username,password=password)
14
+ ftp = ssh_client.open_sftp()
15
+ files = ftp.listdir()
16
+
17
+ print("Listing all the files and Directory: ",files)
18
+ # print('connection established successfully')
19
+
20
+ ssh_client.close()