Код: Выделить всё
@app.route("/", methods=['GET', 'POST'])
def upload():
file = request.files['file']
try:
gethostbyname("servername")
except gaierror:
print(gaierror)
exit()
port = 22
if request.method == 'POST':
filePost = request.args.get('filename')
transport = paramiko.Transport("servername", port))
try:
transport.connect(username="user",password="password", hostkey=None)
sftp = paramiko.SFTPClient.from_transport(transport)
except paramiko.ssh_exception.AuthenticationException as e:
print(e)
exit()
path = '/home/'+file.filename
try:
sftp.put(file, path)
except Exception as e:
print(e)
ключ/значение из моего запроса на публикацию (с использованием Postman):
Код: Выделить всё
key:fileКод: Выделить всё
value:test.txtПодробнее здесь: https://stackoverflow.com/questions/723 ... ramiko-put
Мобильная версия