一、添加登录和登出的路由

修改app/home/views.py内容,增加登录("/login/")和登出("/logout/")的路由:

 # coding:utf8
from . import home
from flask import render_template, redirect, url_for @home.route("/")
def index():
return render_template("home/index.html") @home.route("/login/")
def login():
return render_template("home/login.html") @home.route("/logout/")
def logout():
return redirect(url_for("home.login"))

二、创建登录页

创建app/templates/home/login.html文件,内容:

 {% extends "home/home.html" %}

 {% block content %}
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><span class="glyphicon glyphicon-log-in"></span>&nbsp;会员登录</h3>
</div>
<div class="panel-body">
<form role="form">
<fieldset>
<div class="form-group">
<label for="input_contact"><span class="glyphicon glyphicon-user"></span>&nbsp;账号</label>
<input id="input_contact" class="form-control input-lg" placeholder="用户名/邮箱/手机号码"
name="contact" type="text" autofocus>
</div>
<div class="col-md-12" id="error_contact"></div>
<div class="form-group">
<label for="input_password"><span class="glyphicon glyphicon-lock"></span>&nbsp;密码</label>
<input id="input_password" class="form-control input-lg" placeholder="密码" name="password"
type="password" value="">
</div>
<div class="col-md-12" id="error_password"></div>
<a href="user.html" class="btn btn-lg btn-success btn-block">登录</a>
</fieldset>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

三、修改首页导航链接

修改app/templates/home/home.html页面导航中的登录和退出链接的URL:

四、运行查看效果

运行manage.py,并在浏览器访问http://127.0.0.1:5000/login/

尝试点击一下导航中的登录和退出按钮,都会跳转到登录页。

【结束】

(5)Flask项目会员登录页的更多相关文章

  1. CAS—改动默认登录页

    1.  部署CAS-Server 本文以cas-server-3.4.11-release.zip为例.解压提取cas-server-3.4.11/modules/cas-server-webapp- ...

  2. ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(13)之会员登录注册

    源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c 会员中心,是我们与用户交 ...

  3. vue项目前端限制页面长时间未操作超时退出到登录页

    之前项目超时判断是后台根据token判断的,这样判断需要请求接口才能得到返回结果,这样就出现页面没有接口请求时还可以点击,有接口请求时才会退出 现在需要做到的效果是:页面超过30分钟未操作时,无论点击 ...

  4. Flask项目之手机端租房网站的实战开发(八)

    说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 接着上一篇博客继续往下写 :https://blog.csdn.net/qq_41782425/article/details/8 ...

  5. Spring Security笔记:自定义登录页

    以下内容参考了 http://www.mkyong.com/spring-security/spring-security-form-login-example/ 接上回,在前面的Hello Worl ...

  6. Python框架 Flask 项目实战教程

    本文目的是为了完成一个项目用到的flask基本知识,例子会逐渐加深.最好对着源码,一步一步走.下载源码,运行pip install -r requirements.txt 建立环境python db_ ...

  7. flask 项目基本框架的搭建

    综合案例:学生成绩管理项目搭建 一 新建项目目录students,并创建虚拟环境 mkvirtualenv students 二 安装开发中使用的依赖模块 pip install flask==0.1 ...

  8. 登陆页、注册页、会员中心页logo图的替换

                  关闭   PHP在线开发笔记       目录视图 摘要视图 订阅 异步赠书:9月重磅新书升级,本本经典           程序员9月书讯      每周荐书:ES6.虚 ...

  9. react 会员登录

    会员登录在我们的好多项目中都有用到,比如在后台管理系统,它的第一步就需要你进行登录,还有在我们常见的京东.淘宝.网易云音乐等一系列的软件上面都需要进行登录. 下面我们直接上代码 fetch(url,{ ...

随机推荐

  1. php环境Unknown column '*' in 'field list'解决方案

    在使用pymysql 做网站往数据库插入数据时发现如下错误:pymysql.err.InternalError: (1054, "Unknown column '*' in 'field l ...

  2. 命令启用Windows7 .NetFramework 3.5

    最近在测试某系统安装包在各个环境下的安装使用情况,在window7 下使用时,安装完成iis后,发现.Net Framework 3.5 没有自动勾选:命令没有执行成功. 通过以下命令可以在windo ...

  3. Kotlin注解深入解析与实例剖析

    在上一次https://www.cnblogs.com/webor2006/p/11522798.html中学习了Kotlin注解相关的东东,这次继续对Kotlin的注解继续学习: 注解也可以拥有自己 ...

  4. Nastya Hasn't Written a Legend(Codeforces Round #546 (Div. 2)E+线段树)

    题目链接 传送门 题面 题意 给你一个\(a\)数组和一个\(k\)数组,进行\(q\)次操作,操作分为两种: 将\(a_i\)增加\(x\),此时如果\(a_{i+1}<a_i+k_i\),那 ...

  5. 微信小程序~事件绑定和冒泡

    [1]事件绑定和冒泡 事件绑定的写法同组件的属性,以 key.value 的形式. key 以bind或catch开头,然后跟上事件的类型,如bindtap.catchtouchstart.自基础库版 ...

  6. php过滤敏感词

    <?php /**  * 敏感词过滤工具类  * 使用方法  * echo FilterTools::filterContent("你妈的我操一色狼杂种二山食物"," ...

  7. oracle中LPAD和RPAD函数的使用方法(加个人总结)

    今天看到两个没有见过的SQL中的函数,总结一下: 函数参数:lpad( string1, padded_length, [ pad_string ] ) 其中 string1:源字符串 padded_ ...

  8. Generator 函数和for...of循环,实现斐波那契数列

    function* fib () { let [prev, cur] = [0,1] for (;;) { yield cur [prev, cur] = [cur, cur+prev] } } fo ...

  9. jQuery通用遍历方法each的实现

    each介绍 jQuery 的 each 方法,作为一个通用遍历方法,可用于遍历对象和数组. 语法为: jQuery.each(object, [callback]) 回调函数拥有两个参数:第一个为对 ...

  10. hibernate笔记

    1.hibernate中的list()遍历方法和iterator()遍历方法之间的区别 1:返回的类型不一样,list()返回List, iterate()返回Iterator,2: 获取数据的方式不 ...