Python flask 结合 BootStrap写的登录页面

Python flask

from flask import Flask,render_template,request
app=Flask(__name__)

@app.route("/")
def f01():
    return render_template("01.初识BootStrap.html")

@app.route("/login",methods=["POST"])
def login():
    username=request.form.get("username")
    password=request.form.get("password")
    print(username,password)
    if username=="admin":
        if password=='admin':
            return "登录成功"
    else:
        return render_template("a01.登录失败.html")
if __name__ == "__main__":
    app.run()

登录页面html

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- 开发版本 -->
  <link rel="stylesheet" href="static/plugins/bootstrap-3.4.1/css/bootstrap.css">
  <!-- 生成版本 -->
  <!-- <link rel="stylesheet" href="static/plugins/bootstrap-3.4.1/css/bootstrap.min.css"> -->
  <style>
    .login {
      height: 360px;
      width: 500px;
      border: 1px solid #dddddd;
      border-radius: 10px;
      margin: 0 auto;
      margin-top: 200px;
      padding: 30px;
      box-shadow: 5px 5px 20px #aaa;
    }

    .beiJing {
      position: fixed;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      background-color: aquamarine;
    }
  </style>
</head>

<body>
  
  <!-- <div class="beiJing"> -->
    <div class="login">
      <h2 style="text-align: center">用户登录</h2>
      <br>
      <form action="/login" method="POST">
        <div class="form-group">
          <label for="exampleInputEmail1">用户名</label>
          <input type="text" class="form-control" id="exampleInputEmail1" placeholder="请输入用户名" name="username">
        </div>
        <div class="form-group">
          <label for="exampleInputPassword1">密码</label>
          <input type="password" class="form-control" id="exampleInputPassword1" placeholder="请输入密码" name="password">
        </div>
        <button type="submit" class="btn btn-primary" style="float: right;">登录</button>
      </form>
    </div>
  <!-- </div> -->

</body>

</html>

登录失败页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <a href="/">登录失败,点击重新登录!</a>
</body>
</html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值