0

我正在尝试在 slack 中使用 /slash 命令并将变量传递给烧瓶路由内的函数,但不知何故,如果我将所有函数都放在路由内,它就不起作用,但如果我只保留 return 语句,它就起作用。工作条件:

from flask import request
from netmiko import Netmiko
from blueprint import blueprint
from app_data import slackapp
from slackpyez.ui import BLOCKS
S1 = {
    "host": "192.168.250.210",
    "username": "admin",
    "password": "admin",
    "device_type": "arista_eos",
    "session_log": "my_session3.txt",
}
net_connect = Netmiko(**S1)
command = "show version"
output = net_connect.send_command(command, use_textfsm=False)
@blueprint.route("/ngrok", methods=["POST","GET"])
def return_show_version():
    return(output)

我可以得到

在此处输入图像描述

我想传递一个文本变量,以便 IP 地址是动态的,但它不起作用。

from flask import request
from netmiko import Netmiko
from blueprint import blueprint
from app_data import slackapp
from slackpyez.ui import BLOCKS

@blueprint.route("/ngrok", methods=["POST","GET","PUT"])
def return_show_version():
        S1 = {
            "host": request.form["text"],
            "username": "admin",
            "password": "admin",
            "device_type": "arista_eos",
            "session_log": "my_session4.txt",
        }
        net_connect = Netmiko(**S1)
        command = "show version"
        output = net_connect.send_command(command, use_textfsm=False)
        return(output)

结果如下:

ngrok failed with the error "operation_timeout"
4

0 回答 0