I have an html form where a user can enter a stock ticker. After submitting the ticker I'd like the app to redirect to a url that has the entered ticker in the url path and returns the ticker name.
Code:
@app.route('/', methods=['GET', 'POST'])
def stockInfo():
if request.method == "POST":
ticker = request.form['ticker'].upper()
return redirect('/<ticker>')
return render_template('home.html')
@app.route('/<ticker>', methods=['GET', 'POST'])
def success(ticker):
return '<h1>The ticker' + ticker + 'was entered </h1>'
What I would like to happen is when the user submits the ticker "NFLX" it routes to /NFLX and returns "The ticker NFLX was entered"