flask 实现一个简单的登录


DOCTYPE html>
<html lang="en">
<head>    <meta charset="UTF-8">
    <title>第一个网页标题title>
head>
<body>
    <form action="/userName" METHOD="get">
        登录名:<input type="text" name="uname" id="uname"><br/>
        密码:<input type="password" name="password" id="password"><br/>
        <input type="submit" value="登录" >
        <input type="button" value="退出" >
    form>
 body>
html>
##login.py
from flask import Flask,render_template,request

app=Flask(__name__)
@app.route('/login')
def login():
    return render_template('index3.html')
    #return '离开据了解'
name={'username':'zhangsan','psd':'123456'}
@app.route('/userName')
def userName():
    uname=request.args.get('uname')
    #判断用户名是否正确
        return  f"主页,欢迎登录{uname}"
app.run(debug=True)

你可能感兴趣的:(flask,python,后端)