zoukankan      html  css  js  c++  java
  • Flask实战第47天:首页导航条首先和代码抽离

     新建一个前台页面的父模板front_base.html

    导航条是总boostrap v3中文站拷贝过来的,然后根据自己的需求做一些修改

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="csrf-token" content="{{ csrf_token() }}">
        <title>{% block title %}{% endblock %}</title>
        <script src="http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
        <link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
        <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script src="{{ url_for('static', filename='common/js/bbsajax.js') }}"></script>
        <link href="{{ url_for('static', filename='common/sweetalert/sweetalert.css') }}" rel="stylesheet">
        <script src="{{ url_for('static', filename='common/sweetalert/sweetalert.min.js') }}"></script>
        <script src="{{ url_for('static', filename='common/sweetalert/xtalert.js') }}"></script>
        {% block head %}{% endblock %}
    </head>
    <body>
    
        <nav class="navbar navbar-default">
          <div class="container-fluid">
            <div class="navbar-header">
              <a class="navbar-brand" href="#">何波安BBS论坛</a>
            </div>
    
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
              <ul class="nav navbar-nav">
                <li><a href="#">首页</a></li>
              </ul>
              <form class="navbar-form navbar-left">
                <div class="form-group">
                  <input type="text" class="form-control" placeholder="请输入关键字">
                </div>
                <button type="submit" class="btn btn-default">搜索</button>
              </form>
              <ul class="nav navbar-nav navbar-right">
                <li><a href="#">登录</a></li>
                <li><a href="#">注册</a></li>
              </ul>
            </div>
          </div>
        </nav>
        
        {% block body %}{% endblock %}
    
    </body>
    </html>
    front_base.html

    新建首页front_index.html继承front_base.html

    {% extends 'front/front_base.html' %}
    
    {% block title %}首页-BBS论坛{% endblock %}
    
    {% block head %}{% endblock %}
    
    {% block body %}这是首页内容{% endblock %}

    修改视图,编辑front.views.py

    @bp.route('/')
    def index():
        return render_template('front/front_index.html')

  • 相关阅读:
    csrf 跨站请求伪造
    apache 根据端口访问配置
    对于表单中单双引号问题
    svn常用命令
    urlencode和rawurlencode的区别
    php 显示某一个时间相当于当前时间在多少秒前,多少分钟前,多少小时前
    javaweb基础(24)_jsp一般的标签开发
    javaweb基础(23)_jsp自定义标签
    javaweb基础(22)_Servlet+JSP+JavaBean实战登陆
    javaweb基础(21)_两种开发模式
  • 原文地址:https://www.cnblogs.com/sellsa/p/9534762.html
Copyright © 2011-2022 走看看