Flask -- route

Source: Internet
Author: User
Flask -- route there are three methods for routing flask (example:
  1. Flask. flask. route decorator (for more information about decorator, see this article). In this case, add the desired route to the parameters of the decorator. The parameter can be expressed as <>
  2. Flask. Flask. add_url_rule Function
  3. Use the flask underlying werkzeug to provideFlask. Flask. url_map Function
Processing of the last "/" in the route

Flask regards "/" as a path similar to the path in the Linux file system. Therefore, when there is no final "/" in the route, this path is equivalent to a file in the file system, in this case, if the input path contains "/", the server will produce a 404 error. If there is a final "/", this path is equivalent to the directory of the file system, therefore, if the input path does not contain "/", flask automatically jumps to the path with "/", that is, a directory is opened.

Routing Parameters

Parameters are as follows:<Converter: Name> indicates the parameter type, and converter indicates the parameter type. There are four available types:

String Accepts any text without a slash (the default)
Int Accepts Integers
Float LikeIntBut for floating point values
Path Like the default but also accepts slashes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.