![]() A popular choice is Redis, which is easy to set-up and use. Flask-Cache can be configured to work with a bunch of different caching backends. This extension provides us with a decorator that we can use on our index view to cache the response for some period of time. Finally, to issue a redirect to the ticker page, we use the redirect function from Flask and pass in the URL we want to send users to. Specifically, we’re going to use the Flask-Cache extension. The request that we can import from Flask can be used within routes to get information about the current request that Flask is serving. Once we have the routing set up, we can access the form data through Flask's request object. To demonstrate the use of a POST method in a URL route, first let us create an HTML form and use the POST method to send form data to the URL. ![]() This route is going to receive a POST request from the HTML form, so we need to explicitly tell Flask to route POST requests to it by passing "POST" into the optional methods argument to the route decorator, like so methods=) By default, the Flask route responds to GET requests.However, you can change this preference by providing method parameters for the route decorator. By default, Flask assumes routes you define are responding to GET requests. So far we have only been dealing with GET requests (when our browser requests a page). To support a form, we're going to need to a route that accepts the input and redirects users to the right page. Update any references to the path in url_for with the prefix being the name of the blueprint ( home.index). ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |