1
@app.route('/', methods=['POST'])
def value():

    port=22
    para1 = request.form['input1']
    para2 = request.form['input2']
    para3 = request.form['input3']
    ssh_client=paramiko.SSHClient()
    ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    ssh_client.connect(hostname=para1,port=port,username=para2,password=para3)
    return render_template('index.html')

I have a function like this that receives values from the HTML form, and I want to pass the value of para1, para2, para3 to anther function.

I try return render_template('index.html'), para1, para2, para3 or return render_template('index.html', para1, para2, para3)

Both of them do not work.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Berlin Bolin
  • 77
  • 1
  • 7
  • `return render_template('index.html'), para1, para2, para3` is clearly not going to work, that's passing a single argument to `render_template` and returning a tuple from `value`. Could you expand on how `render_template('index.html', para1, para2, para3)` doesn't work? Give a [mcve]. – jonrsharpe Feb 06 '20 at 22:08
  • To exactly which function you want provide that variables? – bc291 Feb 06 '20 at 22:40
  • According to flask docs: *All you have to do is provide the name of the template and the variables you want to pass to the template engine as **keyword arguments**.* `render_template('index.html', para1=para1, para2=para2, para3=para3)` – bc291 Feb 06 '20 at 22:42
  • 1
    @KennyAires No, that's `SyntaxError`. – bc291 Feb 06 '20 at 23:09
  • my bad, you're right – Kenny Aires Feb 06 '20 at 23:10

0 Answers0