0

So I have a html form input and basically I want to take the value that I input and pass it into my app.route(/sometext/inputvalue)

 @app.route('/inputvalue')
def index():
  return render_template('index.html')
Kush Patel
  • 11
  • 1
  • 4

1 Answers1

1

You need to capture the form request by the app, by using POST GET methods. so for that you need a login method. something like this.

# you don't need to redirect the template
from flask import Flask, redirect, url_for, request
@app.route('/login', methods=['POST', 'GET'])
def login():

    if request.method == 'POST':
        user = request.form['Email'] # suppose you have a email and password field
        passe = request.form['passw']

        return redirect(url_for('index', inputvalue=user)) # then you can pass email or pass

and after these things are done and the servers are running, open your html file and fill the form. you can see the redirected values by,

@app.route('/inputvalue')
def index(inputvalue):
  return ('hey' + inputvalue)
P.hunter
  • 1,345
  • 2
  • 21
  • 45