美文网首页
Flask-login-1

Flask-login-1

作者: 米粒_f37b | 来源:发表于2021-01-04 23:38 被阅读0次

也不知道为啥想研究Flask,感觉就想用它做个页面,后面自己可以在自己的页面里面为所欲为,在此记录一下作为纪念,实现登录页面的完整过程


设计思路:一、前端需要一个登录页面,登录页面需要有输入框进行用户名和密码的输入;二、需要路由进行触发函数:get请求的路由进行登录页面的展示,post请求的路由进行登录操作进行用户名和密码的校验操作

代码如下:

run.py

from flask import Flask,request,render_template

app = Flask(__name__)

@app.route('/login',methods=['GET','POST'])
def login():
    if request.method == 'GET':
        pass
    if request.method == 'POST':
        pass
    else:
        return render_template('login.html')

if __name__ == '__main__':

    app.run(debug=True)

templates/login.html

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>login-web</title>

</head>

<body>

<form method="post">

    username:<br>

    <input text="username" type="text">

    <br>password:<br>

    <input text="password" type="text">

</form>

</body>

</html>

相关文章

  • Flask-login-1

    也不知道为啥想研究Flask,感觉就想用它做个页面,后面自己可以在自己的页面里面为所欲为,在此记录一下作为纪念,实...

网友评论

      本文标题:Flask-login-1

      本文链接:https://www.haomeiwen.com/subject/xagboktx.html