How to call multiple routes inside one route?

后端 未结 1 1941
遇见更好的自我
遇见更好的自我 2021-01-16 03:25

I have a dashboard.html page which contains three tabs. The view of these tabs by look is same but has different functionality as they are rendered from differe

1条回答
  •  没有蜡笔的小新
    2021-01-16 04:02

    I can find two ways to make tab show: 1. Using ajax and embed HTML 2. Using page load by inherit layout in sub-layout

    1.Using Ajax (I am using JQuery Ajax)

    // Python
    @app.route('/get-tab/')
    def get_tab(id):
        return render_template('tab-template.html')
    
    // View
     {% extends 'layout/base.html' %}
    
     {% block content %}
         
         
         
    {% endblock %}

    Demo: http://phearaeun.pythonanywhere.com/child

    2.Inherit base layout to sub layout

    --> Base Layout
        --> Child layout
            --> Template
    
    // Base Layout
    ...
    
    {% block content %}{% endblock %}
    
    ...
    
    // Child layout to inherit base layout
    ...
    {% extends 'layout/base.html' %}
    {% block content %}
       // Header content
       {% block subcontent %}{% endblock %}
    {% endblock %}
    ...
    
    // Template to inherit child layout
    ...
    {% extends 'layout/child.html' %}
    {% block subcontent %}
    
    {% endblock %}
    

    0 讨论(0)
提交回复
热议问题