zoukankan      html  css  js  c++  java
  • flask开发用户管理系统wtf版

    #coding=utf-8
    from flask import Flask
    from flask import request
    from flask import redirect
    from flask import render_template
    from wtforms import Form, TextField, PasswordField, validators
    
    app = Flask(__name__)
    
    class LoginForm(Form):
        username = TextField("username", [validators.Required()])
        password = PasswordField("password", [validators.Required()])
    
    @app.route("/user", methods=["GET", "POST"])
    def login_checked():
        myForm = LoginForm(request.form)
        if request.method == "POST":
            if not myForm.username.data:
                message = "please input your username"
                return render_template("index.html", message=message, form=myForm)
            if not myForm.password.data:
                message = "please input your password"
                return render_template("index.html", message=message, form=myForm)
            if myForm.username.data == "lala" and myForm.password.data == "123456" and myForm.validate():
                return redirect("http://www.taobao.com")
            else:
                message = "your username or password is wrong"
                return render_template("index.html", message=message, form=myForm)
        return render_template("index.html", form=myForm)
    
    
    if __name__ == "__main__":
        app.run(port=8080)
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>user management</title>
    </head>
    <body>
        <div align="center">
        <h1>user management</h1>
            {% if message %}
            {{ message }}
            {% endif %}
    
        <form method="post" name="form">
            username : {{form.username}}
            <br/>
            password : {{form.password}}
            <br/>
            <input type="submit" name="submit" value="submit">
            <input type="reset" name="reset" value="reset">
        </form>
        </div>
    
    
    </body>
    </html>
  • 相关阅读:
    RBF高斯径向基核函数【转】
    Libsvm自定义核函数【转】
    .Net对比Java分析
    码云提交
    webapi自定义Filter
    QT4.8.5 连接数据库(读写数据)
    axure8.0激活
    photo型的object转byte[]
    select拼接
    【转】easyui $.message.alert 点击右上角的关闭按钮时,不执行定义的回调函数
  • 原文地址:https://www.cnblogs.com/themost/p/8546985.html
Copyright © 2011-2022 走看看