Course Content

  • StatusCodeErrorDemo

Course Content


The redirect() function is available in the Flask class. It returns a response object and redirects the user to a different destination location with the provided status code when it is invoked. The location argument specifies the URL to which the response should be forwarded.

location – the address to which the response should be redirected. The reroute status code is code. The default value is 302.
Response (class) – a Response class that can be used to create a response. werkzeug. wrappers is the default. If the response isn't specified, it'll be ignored.

from flask import * app = Flask(__name__) @app. route("/", methods=["POST", "GET"]) def home(): return render_template("index. html") # This function gets param1 from url yourflaskroot/getdata # which was the url set in ajax code and return param1 back to it # you can write a simple ajax code to test it out @app.

In Flask, url for is used to create a URL to avoid the overhead of changing URLs throughout an application (including in templates). If the root URL of your app changes without url for, you'll have to replace it on every page where the link appears.

Hyperlinks are used to connect two pages on a website. In Flask, this is accomplished by utilising the well-known anchor tag (a href="">link text/a>). The route defined in the file is used to set the href destination in Flask.

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
Apple App Store
598K+ Downloads
App Download Section Circle 1
4.57 Avg. Ratings
App Download Section Circle 2
15K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere