Decorator comb achieve specific routing
Flask has two core: Werkzeug and Jinja2
- Werkzeug实现路由、调试和Web服务器网关接口
- Jinja2实现了模板。
Werkzeug WSGI protocol to follow is a python library
- 其内部实现了很多Web框架底层的东西,比如request和response对象;
- 与WSGI规范的兼容;支持Unicode;
- 支持基本的会话管理和签名Cookie;
- 集成URL请求路由等。
Werkzeug library routing module responsible for implementing URL parsing. Different views of the function corresponding to a URL, URL routing module will request information by analyzing a view corresponding to the URL matching function, the function is executed in order to generate a response message.
routing inside the module are:
- Rule class
- URL patterns for different configurations of objects, URL routing rules
- Map class
- URL stores all the rules and some configuration parameters
- BaseConverter subclass
- Responsible for defining the matching rules
- MapAdapter class
- Responsible for coordinating the Rule of work to do specific match