в моем views.py у меня есть def, который на самом деле выполнит некоторую конфигурацию в устройстве, я сохраняю вывод в переменной для результатов, и я хотел бы перенаправить на «home», когда запрос будет выполнен, и в то же время создайте всплывающее окно html, в котором будут отображаться результаты.
Expl: в файле views.py у меня есть следующий код:
def pstn_nanp_pri_ca(request):
if request.method == "POST":
result = []
selected_device_id = request.POST['device']
circuit_id = request.POST['circuit_id']
pri_channel = request.POST['pri_channel']
dev = get_object_or_404(Device, pk=selected_device_id)
PSTN_slot = dev.PSTN_Slot
# dev.ip_address dev.username, dev.password, dev.site_code
try:
` ip_address = dev.ip_address
# STATIC Username and Password
username = dev.username
password = dev.password
#
# Initiate SSH Connection to the router
#
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname=ip_address, username=username, password=password)
print("Successful connection", ip_address)
remote_connection = ssh_client.invoke_shell()
time.sleep(2)
remote_connection.send("configure terminal\n")
time.sleep(2)
#
#
# PRI Config
#
#
remote_connection.send("card type t1 0 " +str(PSTN_slot[2])+ "\n")
remote_connection.send("isdn switch-type primary-ni\n")
remote_connection.send("controller T1 " +str(PSTN_slot)+ "\n")
remote_connection.send("Description ## PRI Circuit ID : " +str(circuit_id)+ " ###\n")
remote_connection.send("framing esf\n")
remote_connection.send("clock source line primary\n")
remote_connection.send("linecode b8zs\n")
remote_connection.send("cablelength long 0db\n")
remote_connection.send("pri-group timeslots 1-" +str(pri_channel)+ "\n")
time.sleep(2)
remote_connection.send("voice-card 0/1\n")
remote_connection.send("dsp services dspfarm\n")
remote_connection.send("voice-card 0/4\n")
remote_connection.send("dsp services dspfarm\n")
remote_connection.send("interface Serial" +str(PSTN_slot)+":23\n")
remote_connection.send("description ## PRI Circuit ID " +str(circuit_id)+ " ###\n")
remote_connection.send("no ip address\n")
remote_connection.send("encapsulation hdlc\n")
remote_connection.send("isdn switch-type primary-ni\n")
time.sleep(2)
remote_connection.send("isdn incoming-voice voice\n")
remote_connection.send("isdn supp-service name calling\n")
remote_connection.send("isdn outgoing display-ie\n")
remote_connection.send("network-clock synchronization automatic\n")
remote_connection.send("network-clock input-source 1 controller T1 "+str(PSTN_slot)+"\n")
time.sleep(2)
result.append(output.decode())
ssh_client.close
return redirect('home')
else:
devices_CA = Device.objects.filter(site_location="CA", device_type="router")
context = {
'devices': devices_CA,
'mode': 'Configure PSTN PRI USGW'
}
return render(request, 'config-pstn-pri-ca.html', context)
, если я могу добавить к return redirect ('home') - всплывающее окно, в котором будет отображаться содержимое результата [] - это то, что я ищу