def delete_files(request): global client if(client != None and client.connected): res = client.delete(request["body"]["file"]) return response("true") else: return response("false")
def list_directory(request): global client if(request["method"] != "POST" or client == None or client.connected != True): return response("false") abs_path = request["body"]["path"] files = client.list_directory(abs_path) return response(files, content_type="application/json")
def upload(request, folder=False): global client if(client != None and client.connected): files = select_files(folder=folder) location = request["body"]["path"] if(type(files["selected"]) == tuple and len(files["selected"]) > 0): if(files["folders"]): client.upload_folders(location, files["selected"]) else: client.upload_files(location, files["selected"]) return response() return response(status=404)
def ssh_connect(data): if(data["method"] != "POST"): return response(status=404) global client client = ssh.SSH( host = data["body"]["host"], username = data["body"]["username"], password = data["body"]["password"] ) connect = client.connect() if(connect == True): return response("true") return response(str(connect))
def exec(request): global client if(client != None and client.connected): command = request["body"]["command"] data = client.exec(command, False) return response(data) return redirect(status=404)
def shell(request): global client if(client != None and client.connected): return response("In development") return render("shell.html", { "host": client.host, "user": client.username }) return redirect("/")
def download(request): global client if(client != None and client.connected): client.download("app.js", request["body"]["file"]) return response() return response(status=404)
def write_file(request): global client if(client != None and client.connected): client.write_file(request["body"]["path"], request["body"]["content"]) return response("true") return response(status=404)
def read_file(request): global client if(client != None and client.connected): content = client.read_file(request["body"]["path"]) return response(str(content)) return response(status=404)
def create_folder(request): global client if(client != None and client.connected): client.create_folder(request["body"]["location"], request["body"]["name"]) return response("success") return response(status=404)
def rename(request): global client if(client != None and client.connected): client.rename(request["body"]["path"], request["body"]["original"], request["body"]["updated"]) return response("success") return response(status=404)