Problem with Flask: don’t have a redirect to a new page

  flask, python

I have this:

file: run.py

 from flask import Flask, render_template, request, url_for import
 pyodbc  # Libreria conexión ODBC para Python import locale import
 pandas as pd from werkzeug.utils import redirect
 
 
 app = Flask(__name__)
 

 @app.route("/") def index():
     return render_template("index.html")
 
 
 @app.route("/", methods=["GET", "POST"]) def request():
     pedido = request.args.get['pedido']
     cliente = request.args.get['cliente']
     return redirect(url_for('coste_transporte', pedido=pedido, cliente=cliente))
 
 
 @app.route("/<int:pedido_sap>", methods=["GET", "POST"]) def
 coste_tranporte(pedido_sap, cliente_final):
     code
     return render_template("pedido.html")

I try to show a index.html in the url "localhost:5000", and when the user complete the form with a input named "pedido" and check "Yes or no" radio button, redirect to url "localhost:5000/123456789" when "123456789" is the number of "pedido".

Thank you.

Source: Python Questions

LEAVE A COMMENT