Flask Notes
Notes about Jinja2
- Inheritence in jinja2: If a child html file extends a parent html file, and
{% extends 'parant.html' %}is written, when the Jinja returns the contents of child.html, only the contents ofparent.html, contents before where{% extends 'parant.html' %}was written and the contents surrounded by{% block blabla %}inchild.htmlwill be returned.
parent.html:
<!DOCTYPE html>
<html>
<body>
<p>some contents</p>
{% block ablock %}
<p>contents will be replaced by child.</p>
{% endblock %}
</body>
</html>
child.html:
<p>
contents before the "extends", will be returned.
</p>
{% extends "parent.html" %}
{% block ablock %}
<p>these contents will be returned instead of the contents in parent.html. </p>
{% endblock %}
<p>
Any contents below "extends", and not surrounded by "block" will not be returned.
</p>
Final returned contents:
<p>
contents before the "extends", will be returned.
</p>
<!DOCTYPE html>
<html>
<body>
<p>some contents</p>
<p>these contents will be returned instead of the contents in parent.html. </p>
</body>
</html>
Difference between 127.0.0.1 and 0.0.0.0
In ipv4, all addresses with prefix 127 are loop back addresses. Any requests sent to a loop back address will be looped back, as if the device receives the request rather than sending the request.
0.0.0.0 means invalid, unknown or non-applicable target. However, on general 0.0.0.0 represents all the ipv4 addresses a device has, if that device is not a router. With an application listening to 0.0.0.0, all requests sent to any addresses the target has will be processed.
Therefore, in some sense, 0.0.0.0 represents local machine actually.
浙公网安备 33010602011771号